Frames Control Script, such a simplescript fails to work

They have: 74 posts

Joined: Sep 2000

I was trying to make a script that made sure that the _top.location was the right frameset page... index.html.


FrameURL = "index.html"
function framesCheck() {

if (top.location.href != "FrameURL") {
alert("You are now being redirected to the proper Home Page.")
top.location.href = FrameURL
}
}The problem is that the scipt just continously reloads index.tml while giving me an alert again and again. I tried removing and quotation marks to the variable-value and around "frameURL" in the if statement. that didnt work. can some1 help,

hehe

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

var FrameURL = "index.html"?

druagord's picture

He has: 335 posts

Joined: May 2003

i think that top.location.href contains the full URL and not just the page replace
the alert with

alert(top.location.href );'

like this you will see what it contains

IF , ELSE , WHILE isn't that what life is all about

They have: 74 posts

Joined: Sep 2000

the var thing wasnt it, though i cant beleive i had forgotten to put it, and druagord, im assuming u made a mistake in your post, what does the alert have to do with anything?

hehe

druagord's picture

He has: 335 posts

Joined: May 2003

it as nothing to do with anything but you could see if top.location.href contains index.html or yoursite.com/index.html

druagord's picture

He has: 335 posts

Joined: May 2003

And by the way remove the "" around FrameURL in the if condition this is probably your probleme since index.html will never be equal to FrameURL

They have: 74 posts

Joined: Sep 2000

ya thanks that was it, top.location.href is the entire URL, not the relative, i had overlooked that, i redid the script to set a variable to the part of the URL after the last slash. and replaced top.location.href with that variable and now its working perfect. thanx for ur help

hehe

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.