Tuesday, March 22, 2011

Javascript: popup a window when clicking a link


code:
<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
    newwindow=window.open(url,'name','height=360,width=480');
    if (window.focus) {newwindow.focus()}
    return false;
}

// -->
</script>
<a href="http://www.youtube.com/v/qrO4YZeyl0I" onclick="return popitup('http://www.youtube.com/v/qrO4YZeyl0I')"> popup Bad Romance</a>

Result, click the following link to popup a youtube video.

popup Bad Romance
 You can resize the window to the size you want.

No comments:

Post a Comment