javascript redirect

monsterm

New Member
Messages
44
Reaction score
0
Points
0
i found a simple script to detect ur browser on my site and it redirects ur frowser to that page

HTML:
<script type="text/javascript">
if(navigator.appName == "Netscape")
{
 window.location = "/main/home.php"
}
 if(navigator.appName == "Microsoft Internet Explorer")
{
 window.location = "/app/monster%20matt.application"
}
</script>
what i want to know is that i put this script in my loading page witch takes 5 sec to redirect the user to the other page but with this script it redirects thr person instantly and i tryed to insert this code to the script abov

HTML:
<script type="text/javascript">
<!--
function delayer(){
    window.location = "../javascriptredirect.php"
}
//-->
</script>
</head>
onLoad="setTimeout('delayer()', 5000)"

but it didnt work can u help me out here

EDIT: ummm i saw that this was in there
HTML:
function delayer(){
    window.location = "../javascriptredirect.php"

so what im guessing is that i might only need

HTML:
<script type="text/javascript">
<body onLoad="setTimeout('delayer()', 5000)">
}
</script>

but where do i put the setTimeout scripit in this one


HTML:
<script type="text/javascript">
if(navigator.appName == "Netscape")
{
 window.location = "/main/home.php"
}
 if(navigator.appName == "Microsoft Internet Explorer")
{
 window.location = "/app/monster%20matt.application"
}
</script>
thx for the help if u can
 
Last edited:

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
try having this:
HTML:
<script type="text/javascript">
//this will start the timer as soon as the page finishes loading
window.onload = setTimeout("redirector()", 5000);

//this is the actuall redirect
function redirector(){
  if (navigator.appName == "Netscape") {
    location.href = "http://server.tld/main/home.php"
  } else if (navigator.appName == "Microsoft Internet Explorer") {
    location.href = "http://server.tld/app/monster%20matt.application"
  }
}
</script>

I have some corrections to your code. First of all, you should use location.href instead of window.location , see this forum thread. Next, I believe that there is more efficient ways of finding the type of browser, but I will let you search it, since I don't have much time at hand now. You should also add a fallback page for browser other than Netscape and MSIE. Oh ad BTW, Microsoft has released a plugin for FF which enables ClickOnce support.
 
Last edited:

monsterm

New Member
Messages
44
Reaction score
0
Points
0
cool and 1 question

i looked up OnceClick support but i dont get it whats it for
 

taha116

Member
Messages
505
Reaction score
0
Points
16
http://forums.x10hosting.com/progra...different-webpage-depending-browser-type.html

<SCRIPT>
if (navigator.appName == "Microsoft Internet Explorer")
document.write('<META HTTP-EQUIV="REFRESH" CONTENT="1;URL=msie.html">');
else
document.write('<META HTTP-EQUIV="REFRESH" CONTENT="1;URL=netscape.html">');
</SCRIPT>

Replace the part were it says content = 1 to whatever number of seconds you want so if u want 5 seconds replace the 1 with a 5....

Simple
 
Top