Jump to content

Open a New Window


locbtran

Recommended Posts

when a user click on a link, it would open a new window in HTML it is something like this:

<a href="http://google.com" target="_blank">click here</a>

How do I do this in Javascript? So a user would click on the link and it would open a new window. Here's my code

document.writeln('<tr><td>' + "http://google.com" + '</td></tr>');

I know window.open(url) would open a new window, but how do I make it clickable??Any comments or suggestion would be greatly appreciated. thanks

Link to comment
Share on other sites

The simplest technique is to embed an onclick handler in the tag you want to make clickable. Look here: http://www.w3schools.com/jsref/event_onclick.aspIf the embedded code gets long, you might move it into a function in your script, and then the code embedded in your tag would simply call that function.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...