SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member tomcromp's Avatar
    Join Date
    Nov 2003
    Location
    london
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    firefox redirect script with wordpress

    Hello added a firefox redirect script to my site but when i view the site in firefox it just keeps refreshing.
    The code is:
    <html>
    <script>
    if(navigator.userAgent.indexOf("Firefox") != -1)
    {
    window.location = "http://www.watch-movies-online.co.uk";
    }
    else
    {
    window.location = "http://www.mozilla.org/products/firefox/";
    }
    </script>
    </html>
    Any one know whats wrong?

    Cheers
    Tom

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Load page,
    where if you have firefox then load page,
    where if you have firefox then load page,
    where if you have firefox then load page,
    ...

    Try instead

    Code javascript:
    if(navigator.userAgent.indexOf("Firefox") === -1) {
        window.location = "http://www.mozilla.org/products/firefox/";
    }
    Last edited by paul_wilkins; Aug 20, 2008 at 15:40.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member tomcromp's Avatar
    Join Date
    Nov 2003
    Location
    london
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that doesn't re-direct in internet explorer. try on watch-movies-online.co.uk

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    The code on your page is broken so no the script isn't going to work.

    There's a missing brace in the if statement. Add an opening brace to the end of the if statement line and it will work

    Code javascript:
    if(navigator.userAgent.indexOf("Firefox") === -1) { // <-- this brace here
        window.location = "http://www.mozilla.org/products/firefox/";
    }
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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