Jump to content

Making button behave like anchore (<a href="www...")


Guest Alex Richardson

Recommended Posts

Guest Alex Richardson

I am trying to make a button behave like an anchor. When I click the button I navigate to a new page. My first geuss would be to use some javascript, something like window.open(...). All of those open new windows. I need the new page to be opened in the same spot. Any suggestions?

Link to comment
Share on other sites

location is just a property of the window, according to W3C standards.
The top object refers to the topmost frame, but in this case that would be synonymous with the window object.
And since when the capital C in "onclick"?
In HTML event attributes can use lowerCamelcase. Not in XHTML though.
Link to comment
Share on other sites

Instead you could use
<input type="button" onClick="java script:top.location.replace("URL") value="Click here" />

The top.location.replace tends to work more in versions of IE and FF.

Actually the replace method loads the specified URL over the current history entry. After calling the replace method, the user cannot navigate to the previous URL by using browser's Back button. That may not be the intent in this case.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...