Skip navigation
Currently Being Moderated

How to properly redirect browsers?

Jul 2, 2012 4:46 PM

Hi Everyone,

 

I am not a developer, but am trying to figure out how to redirect browsers going to my website.  I've set up a separate html doc with this javascript code in my head tag:

 

 

<script language="JavaScript"

type="text/JavaScript">

if(navigator.appName == "WebTV")

{

window.location = "http://s364852370.onlinehome.us/HarmonicMotion/HarmonicMotionII/browse r.html"

}

if(navigator.appName == "Google Chrome")

{

window.location.href = "http://s364852370.onlinehome.us/HarmonicMotion/HarmonicMotionII/Harmon icMotionII.html"

}

if(navigator.appName == "Netscape")

{

window.location = "http://s364852370.onlinehome.us/HarmonicMotion/HarmonicMotionII/browse r.html"

}

if(navigator.appName == "Microsoft Internet Explorer")

{

window.location = "http://s364852370.onlinehome.us/HarmonicMotion/HarmonicMotionII/browse r.html"

}

window.location == "http://s364852370.onlinehome.us/HarmonicMotion/HarmonicMotionII/Harmon icMotionII.html"

</script>

 

The thing is, it seems to work on my browsers, but google chrome is not being directed to the place I specify.  Rather it redirects to the same page as all the out of date browsers.  Is my javascript not compatible with Chrome?  and if so is there an other way to do this?  I heard Javascript is testy with redirects, but couldn't find a better way to do this online.  Let me know if I am doing something drastically wrong.

 

Thanks,

 

HM

 
Replies
  • Currently Being Moderated
    Jul 2, 2012 5:06 PM   in reply to HarmonicMotion

    Javascript browser sniffing is a dated, and not wholly reliable, approach which generates a lot of work for the web designer.

     

    It has largely been replaced by responsive web design and progressive enhancement techniques.

     

    http://coding.smashingmagazine.com/2011/01/12/guidelines-for-responsiv e-web-design/

     

    https://www.google.com.au/search?q=responsive+web+design

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 2, 2012 6:50 PM   in reply to HarmonicMotion

    Netscape is a dead browser. Hasn't been used by anyone in years.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points