Simple PopUp Window - the right way.

3 posts Page 1 of 1
Contributors
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

OK, So here is how you do a simple popup window the right way.
First create a HTML page
(example.html)
Code: Select all
<html>
<head>
<title> Simple Javascript PopUp Window </title>
</head>
<body>

</body>
</html>
Now in the head section of the example.html file place this javascript code.
Code: Select all
<head>
<title> .....  </title>

<SCRIPT language=JavaScript type=text/javascript>
<!-- Begin
function winopen(url,a,b){
     newwin=window.open(url,a,b)
}
// End -->
</SCRIPT>

</head>
now in the body section place this code.
Code: Select all
<body>

<a href="javascript:winopen('http://www.popuptest.com/popup3.html','blank','width=450,height=235,status=yes')">Simple PopUp Window</a>

</body>
What this does is creates a client side function that will open a new window or a popup if you want to call it that.
Break Down
this part is the function:
winopen(url,a,b)
winopen = is the function name
the items between the ( ) are args(arguments)
URL = http://www.popuptest.com/popup3.html
a = blank or is the title for the window (not the page title)
b = width and height of the window

A example of this code can bee seen here ( Example PopUp Window )
simple_popup_window.zip
You do not have the required permissions to view the files attached to this post.
Last edited by Scottie1972 on Tue Mar 01, 2011 1:47 am, edited 1 time in total.
Image
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Cool! It works. Did you figure this out yourself or from the net? I never could have found it out myself.
Also, know any other resource sites for learning stuff like this?
+rep to you :)
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Well, Javascript has been more of a hobbie then anything else. I just like to play with it to see what I can do with it.

Add yes there are alot of sites out there with javascript examples. But you really need to have an idea of what you would like to do so you can search alot easier.

Plus alot of javascript samples out there floating on the net will not work. Do to the sytax can be wrong, it could have been writen just to work with certain browsers many reasons why it doesnt work. That is why it is best to experiment and learn what works for you and what you are doing with it.

It helps to keep copys of your scripts in plan text format with notes. This way you can go back to them and find something that you may need from time to time.

Scottie1972
Image
3 posts Page 1 of 1
Return to “Tutorials”