locbtran Posted August 21, 2011 Share Posted August 21, 2011 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 More sharing options...
jeffman Posted August 21, 2011 Share Posted August 21, 2011 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 More sharing options...
Drycodez Posted August 21, 2011 Share Posted August 21, 2011 <a href="java script:window.open('http://google.com')">click here!</a> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.