+ Reply to Thread
Results 1 to 4 of 4

Thread: javascript redirect

  1. #1
    monsterm is offline x10Hosting Member monsterm is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    44

    javascript redirect

    i found a simple script to detect ur browser on my site and it redirects ur frowser to that page

    HTML Code:
    <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 Code:
    <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 Code:
    function delayer(){
        window.location = "../javascriptredirect.php"
    so what im guessing is that i might only need

    HTML Code:
    <script type="text/javascript">
    <body onLoad="setTimeout('delayer()', 5000)">
    }
    </script>
    but where do i put the setTimeout scripit in this one


    HTML Code:
    <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 by monsterm; 07-16-2009 at 08:13 PM.

  2. #2
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: javascript redirect

    try having this:
    HTML Code:
    <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 by xav0989; 07-17-2009 at 06:17 AM. Reason: Some code adjustment
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

  3. #3
    monsterm is offline x10Hosting Member monsterm is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    44

    Re: javascript redirect

    cool and 1 question

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

  4. #4
    taha116's Avatar
    taha116 is offline x10 Lieutenant taha116 is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    497

    Re: javascript redirect

    http://forums.x10hosting.com/program...wser-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


    Need help with starting up your website? No problemo PM if you need help, if you want help with scripts like WordPress, SMF and so on dont be afraid to PM for that too.


+ Reply to Thread

Similar Threads

  1. Making a site JavaScript dependent - pros/cons?
    By Tarzan in forum Programming Help
    Replies: 8
    Last Post: 07-11-2008, 10:08 AM
  2. drop down menus with JavaScript disabled?
    By sifaka in forum Free Hosting
    Replies: 1
    Last Post: 05-15-2008, 10:46 AM
  3. javascript and external javascript files problem
    By delon in forum Programming Help
    Replies: 6
    Last Post: 04-27-2008, 12:41 AM
  4. Redirect
    By BlueIce in forum Free Hosting
    Replies: 3
    Last Post: 10-21-2007, 08:06 AM
  5. XML and Javascript
    By cuteboytm in forum Graphics & Webdesign
    Replies: 1
    Last Post: 09-21-2007, 10:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers