Tuesday, January 8, 2013

Popup Tutor


The code for that popup is this...
<script type="text/javascript">

function popup(){
  cuteLittleWindow = window.open("page.html", "littleWindow", "location=no,width=320,height=200"); 
}

</script>
Place it in between your HEAD tags like any other script. page.html is the url of the html file to load into the popup and 320200 are the width & height of the window.
Then make a link that calls the function...
<a href="javascript:popup()">Here is a popup window.</a>
That's it!
Here is the script on a page all by itself.
What if you wanted a bunch of popup links all on the same page? Easy, just change the function a little to accept any url...
function popup(url){
  cuteLittleWindow = window.open(url, "littleWindow", "location=no,width=320,height=200"); 
}
and then pass a url to it when you click on the link.
<a href="javascript:popup('red.html')">Here is a popup window.</a>

0 comments:

Post a Comment