Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    141
    Thanks
    3
    Thanked 1 Time in 1 Post

    ASK java script redirecting?

    hi guys, I actually have no javascript knowledge at all but I need to do some redirecting stuff
    <html>
    <head>
    <title> my domain.com : Redirecting... </title>
    <script language="JavaScript">
    var time=null
    function move(){
    window.location='http://www.mydomain.com'
    }
    <noscript>
    Please enable your javascript in order to view this page properly...
    </noscript>
    </script>

    </head>
    <body onload="timer=setTimeout('move(),5000')">
    <b>Redirecting to our dedicated server...</b><br>
    If page does not load, please <a href="http://www.my domain.com">click here</a>
    <body>
    </html>
    *********************************************************
    the first thing is . I want to modify this script. this script is working already.
    but I somehow feel unsatisfied.
    let say we have visitor whose browser has java disabled.
    then
    this script will come up with the text:

    Please enable your javascript in order to view this page properly...
    Redirecting to our dedicated server...
    If page does not load, please click here

    I want to ONLY display Please enable your javascript in order to view this page properly ( without the text redirecting..blah bla blha. )

    you know what I am saying?


    oh ya. one more thing.
    is there any html code to replace the text (REdirecting....) from
    Left corner to center?

    Thanks guys.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,633
    Thanks
    0
    Thanked 649 Times in 639 Posts
    So you just want to tell people without JavaScript to go away? If this is a commercial site then the first blind visitor you tell that to will have you in court for discriminating against them.

    Redirects are best done server side either by setting a header record in a server side scripting language or by using a redirect statement in the .htaccess file.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    If server-side is not available...
    Code:
    <html>
    <head>
    <title> my domain.com : Redirecting... </title> 
    <script type="text/javascript"> 
    var time=null; 
    function move(){ 
      window.location='http://www.mydomain.com';
    }
    </script> 
    </head> 
    <body onload="timer=setTimeout('move(),5000')"> 
    <div>
    <script type="text/javascript"> 
    document.write('<div>Redirecting to our dedicated server...</div>');
    document.write('If page does not load, please <a href="http://www.my domain.com">click here</a>');
    </script>
    <noscript> 
    Javascript is disabled, you have to manually <a href="http://www.my domain.com">click here</a> in order to view the page.
    </noscript> 
    </div>
    </body> 
    </html>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •