Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

button javascript works on IE but not firefox window.navigate()

<input type="button" value="Back" onClick="window.navigate('http://www.google.com')">

This works on IE8, but not firefox or opera. Anyone know why and how to fix it?

like image 223
Ian McCullough Avatar asked Jul 10 '09 21:07

Ian McCullough


3 Answers

If you check the documentation for that method, you will see the quite common:

There is no public standard that applies to this method.

This means that it's a non-standard feature that most likely only works in Internet Explorer.

This will work:

<input type="button" value="Back" onclick="window.location.href='http://www.google.com';">

If you are using XHTML:

<input type="button" value="Back" onclick="window.location.href='http://www.google.com';" />
like image 157
Guffa Avatar answered Sep 19 '22 01:09

Guffa


.navigate() only works in IE.

Try setting the window.location.

window.location.href = 'http://www.google.com'
like image 36
Brandon Avatar answered Sep 22 '22 01:09

Brandon


<a href="http://www.google.com">Google</a>
  • links want to be links
  • links afford navigation, buttons afford actions. This is navigation
  • depending on JS is a bad idea

… and "back" is a poor choice of link text. Either a link or your IE specific JS will take the user forward. It will add a URL to the end of the user's history. It won't activate the browser's Forward functionality.

like image 41
Quentin Avatar answered Sep 22 '22 01:09

Quentin