...

View Full Version : Javascript Redirect



OpenIntro
04-08-2004, 09:23 PM
I am attempting to use a redirect so that if a user goes to http://www.zvse.com then they get redirected to http://www.illustro.com/zvse.htm with the code below....



<script language="JavaScript">
if (document.referrer == 'http://www.zvse.com'){
document.location.href='http://www.illustro.com/zvse.htm'
}
</script>


For some reason, it doesn't seem to like the ==. If I change it to != and some different page, it forwards just fine. Both www.illustro.com and www.zvse.com point to the same place but only if the person types in www.zvse.com do we want it forwarded. Any ideas?

Roy Sinclair
04-08-2004, 09:47 PM
document.referrer is the page the user came from and not the page the user is currently on. The page the user is currently on is in document.location.href which is why changing the value of that will cause the page to redirect.

Try:



<script language="JavaScript">
if (document.location.href == 'http://www.zvse.com'){
document.location.href='http://www.illustro.com/zvse.htm'
}
</script>

OpenIntro
04-08-2004, 09:58 PM
This doesn't seem to work either....

Normally, if you go to illustro.com, it opens intro.htm which immediately redirects to a flash page or a no flash page. The flash page, called flash.htm comes up....

I have inserted the code you gave me in both intro.htm and flash.htm and when I go to http://www.zvse.com it doesn't redirect to the correct page :/

Roy Sinclair
04-08-2004, 10:01 PM
I went there and was redirected to the "No Flash" page.

OpenIntro
04-08-2004, 10:07 PM
Well that's because it did not detect that flash was installed ;)

Even so, the redirect to the zvse.htm should occur from intro.htm

Willy Duitt
04-08-2004, 10:27 PM
I was redirected to: http://www.illustro.com/flash.htm



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum