PDA

View Full Version : Can This Be Optimized?



marain
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,

A.


<head>
<title>bigtitle</title>
<script language="JavaScript" type="text/javascript" src="js/popwin.js"></script>
</head>
<body>
.
.
.
<a href="http://www.urlname.com" target="_blank" onclick="popwin('http://www.urlname.com'); return false">Big Link</a>
.
.
.
</body>
function popwin(file) {
window.open(file,'','toolbar=no,left=20,top=20,status=no,width=850,height=500,scrollbars=yes,directories=no,location=no,resizable=yes,menubar=no');
}

vwphillips
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

marain
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.)