views:

110

answers:

3

lets say we have a link

<a href="/something" target="_new">blah</a>

and now i want a button to do the same thing as the link does, without using jquery.

does anyone have experience with something like that?

edit:

This needs to be a link that uses target="_new" because doing that instead of a straight popup is a workaround for some problems IE6 has with opening downloads in popups.

In short: i have a very good reason for using a link, but i started out with a button, so it would be good to not have to style my link to look like button if i can do something with javascript.

+1  A: 

Try using window.open() You may experience problems with pop-up blockers in browsers.

slf
Do they actually block the pop-up if the users clicks himself? I guess the browsers can differ between a "real" click and a simulated event. :-)
Philippe Gerber
A: 

Either of these should work:

<input type="button" onclick="window.open('/something');" value="blah" />
<button type="button" onclick="window.open('/something');">blah</button>
Philippe Gerber
+2  A: 

No scripting required:

<html>
 <body>
  <form method="get" action="http://stackoverflow.com" target="_blank">
   <div><button type="submit">Click me</button></div>
  </form>
 </body>
</html>
Andrew Duffy