View Full Version : Can This Be Optimized?

11-24-2012, 03:52 PM
I want to open "www.urlname.com" in a new window. The code that follows (extraneous stuff excised) works. That is a virtue the value of which is not to be underestimated. Still, a couple of things puzzle me. One is that in the html, the url is specified twice. Also, I do not understand what the "return false" accomplishes. I am hoping someone can take me by the hand and advise whether a better mousetrap stares me in the face.

Best to all,


<script language="JavaScript" type="text/javascript" src="js/popwin.js"></script>
<a href="http://www.urlname.com" target="_blank" onclick="popwin('http://www.urlname.com'); return false">Big Link</a>
function popwin(file) {

11-24-2012, 05:15 PM
you could use

<a href="http://www.urlname.com" target="_blank" onclick="popwin(this.href); return false">Big Link</a>

the return false is to stop the link working when clicked

11-24-2012, 10:11 PM
Yes, that is what return false generally does. However, it does not prevent the link from working here, and I actually want the link to fire every time it is clicked. My impression is that the return false here is superfluous and does nothing. Before removing it, however, I seek the counsel of scriptists more seasoned than I. (In case y'all did not figure it out, I did not write the original script.)