To put the code in a function, just do something like this:
Code:
function closePopup(){
window.opener.location.href = window.opener.location.href;
window.opener.focus();
window.close();
}
Add that JavaScript to your popup page, either in the <head> portion in between <script></script> tags, or in a external .js file which would be referenced in the <head> portion of your document by <script type="text/javascript" src="myjavascript.js"></script>.
Then to call that code, use either an onclick attribute as you mentioned or an anchor element's href attribute.
opt 1)
HTML Code:
<a onclick="closePopup();" href="#">Close Window</a> <!-- You don't have to use the anchor element; this is just an example. -->
opt 2)
HTML Code:
<a href="javascript:closePopup();">Close Window</a>
__________________
The interlocking pieces of web development: usability, performance, accessibility, and standards.
|