Popup Windows


     The infamous Popup Pages. In moderation it`s Ok, if it serves a legitimate purpose ie: a special notice.
     I don`t imagine that anyone enjoys visiting a site that dumps popup after popup filled with unwanted advertising faster then you can close the pages and nasty tricks like hiding the close button or opening in fullscreen mode ect...

       Note* If you can not close a page press Ctrl-Alt-Delete, then fron the taskmanager select the page and click end task. This will close that annoying page.

The following are samples of various types of Popups with the code used to create them.

Onload Popup Window   Onunload Popup Window   Onmouseover Popup
Hidden Popup   Security Popup   Fullscreen Popup
Onclick Javascript Popup   Auto JavaScript Popup   Onclick link & Status bar




TOP of page

OnLoad popup in BODY TAG

     This script will load a Popup Window at the same time the main page loads, which should have happened when this page loaded. The script is added to the BODY tag of the main page. In this case I set the Popup window to show the contents of your C: drive. Here you can set the size of the popup and location from top and left of the screen.

Change 'C:' to point to your popup page.
      ie: 'mypopup.html' or 'www.mydomain.com/html/mypopup.html'



   Attributes

toolbar=YES / NO location=YES / NO directories=YES / NO status=YES / NO
menubar= YES / NO scrollbars=YES / NO resizable=YES / NO copyhistory=YES / NO
width=0 and up height=0 and up top=0 and up left=0 and up


     The following is the script used in the body tag of this page.

< body onload="window.open('C:','Popup_Window',
'toolbar=no,location=no,directories=no,status=no,
menubar=no,scrollbars=no,resizable=no,copyhistory=no,
width=600,height=400,top=30,left=20')" >



TOP of page

OnunLoad popup in BODY TAG

     This script will load a Popup Window at the same time the main page unloads, which should happened when you exit this page. The script is added to the BODY tag of the main page. In this case I set the Popup window to show the web page goodbye.html.
      The script in the popup goodbye.html will close the popup in a few seconds.



   Attributes

toolbar=YES / NO location=YES / NO directories=YES / NO status=YES / NO
menubar= YES / NO scrollbars=YES / NO resizable=YES / NO copyhistory=YES / NO
width=0 and up height=0 and up top=0 and up left=0 and up


     The following is the script used in the body tag of this page.

< body onunload="window.open('goodbye.html','Popup_Window',
'toolbar=no,location=no,directories=no,status=no,
menubar=no,scrollbars=no,resizable=no,copyhistory=no,
width=200,height=200,top=60,left=60')" >



TOP of page

Onmouseover popup link

     When the cursor passes over top of this image it will trigger a popup window. The script to create this popup is in the link tag for the image.

When your mouse is over this picture 
your Browser will open up a popup window.
Mouseover sample



   Attributes

toolbar=YES / NO location=YES / NO directories=YES / NO status=YES / NO
menubar= YES / NO scrollbars=YES / NO resizable=YES / NO copyhistory=YES / NO
width=0 and up height=0 and up top=0 and up left=0 and up


     The following is the script used in the hyperlink tag of this image.

< A onmouseover="window.open('sample.html','Popup_Window',
'toolbar=no,location=no,directories=no,status=no,menubar=no,
scrollbars=no,resizable=no,copyhistory=no,width=400,height=130,
top=30,left=20')" >
< img src="" width="" height="" border="0" >
< /A >


TOP of page

Onmouseover hidden popup link with sound.

     When the cursor passes over top of this image it will trigger a popup window. The script to create this popup is in the link tag for the image. Notice the Popup window is located well off screen and will not be seen. Script in the popup plays a sound loop then closes its` self.

If your cursor goes over this picture a Popup window is opened.
Onmouseover Hidden Popup Sample



   Attributes

toolbar=YES / NO location=YES / NO directories=YES / NO status=YES / NO
menubar= YES / NO scrollbars=YES / NO resizable=YES / NO copyhistory=YES / NO
width=0 and up height=0 and up top=0 and up left=0 and up


     The following is the script used in the hyperlink tag of this image.

< A onmouseover="window.open('sample2.html','Popup_Window',
'toolbar=no,location=no,directories=no,status=no,menubar=no,
scrollbars=no,resizable=no,copyhistory=no,width=29,height=19,
top=1000,left=900')" >< img src=" " width=" " height=" " border="0" >
< /A >


TOP of page

Simple javascript popup security password.

     This is a fairly simple javascript password protection for a webpage. Anyone who knows what they are doing could easly bypass this if they wanted.
     Just place the script anywhere between the body tags. The script is simply a javascript popup with a text entry box. What ever the person enters in the box gets .html added to the end of it. ie: whatever + .html = whaterver.html
     When the OK button is clicked a link to whatever.html is opened. So the password is actually the name of the page.


Click here to access private pages.
Security Popup Sample
(Try the word sorry)



     The following is the script used in the hyperlink tag of this image.

< SCRIPT language="JavaScript">
< !--- Hide from old browsers
function PrivatePage() {
var AccessName = prompt("Please enter your Passkey:", "")
var page=AccessName + ".html" ;
this.location.href = page;
}
// done hiding --- >
< /SCRIPT >

< A HREF="javascript:PrivatePage()">
< img src=" " width=" " height=" " border="0" >
< /A >


TOP of page

Onclick fullscreen popup.

     The full screen Popup window does not have any toolbar or close button. It is often used by unscrupulous advertisers who prey on the unexperienced who do not know how to close the page. Just press ctrl/alt/delete and close the offending page in the taskmanager.
     If you use a fullscreen page be sure to include a visable link or button to close the page.
     The nice part about fullscreen is the maximum viewing area it provides.


This is the code to create a close page link in your Popup page.

< a href="javascript:parent.close()" >CLOSE< /a >



Click me to see the 
popup sample page.
In fullscreen mode.
Click the Spider for Sample fullscreen Popup




     The following is the script used in the hyperlink tag of this image.

< img src=" " width=" " height=" " border="0" style="cursor:hand"
onClick="window.open('sample.html','Popup_Window','fullscreen=yes')" >


TOP of page

Onclick javascript popup alert window.

     This is a JavaScript Popup alert. It can be useful to give a warning or description of the next page. Unfortunately clicking the x (close) button on the JavaScript popup still forwards the Browser to the link. Change the coloured text to suit your needs in the script below. The \r\n in the script stands for new line.

     This sample link will open a popup window which will give you information about your system. The JavaScript on the popup page is from http://javascript.internet.com



Clicking on this image will produce
 a java script popup message.
Click the image for a JavaScript Alert Sample.




     The following is the script used in the hyperlink tag of this image.

< A onclick="javascript:alert('This is an onclick\r\n
JavaScript Alert\r\n\r\nThe following page will analyze
your \r\nComputer and Software\r\nClick to continue.
');
onClick=window.open('sample3.html','Popup_Window','toolbar=no,
location=no,directories=no,status=no,menubar=no,scrollbars=no,
resizable=no,copyhistory=no,width=500,height=500,top=20,left=100
')" >
< img src="" width="" height="" border="0" alt="" >
< /A >


TOP of page


Auto JavaScript popup when page loads.

     This is the script which opened the JavaScript popup alert when this page loaded. The script can be placed anywhere between the BODY tags. Change the coloured text in the script below to suit your needs.



     The following is the script used in the hyperlink tag of this image.

< SCRIPT >
alert("This is an onload\r\nJavaScript Popup Alert.\r\n
\r\nClick OK to view this page.
");
< /SCRIPT >



TOP of page

Onclick link with text in status bar onmouseover and onmouseout.

     This script provides your Popup link with onmouseover and onmouseout text in the status bar of your Browser.



Click me to see the 
popup sample page.
Watch the status bar when you bring
your cursor over and off of this image.



     The following is the script used in the hyperlink tag of this image.

< A onClick="window.open('sample.html','Popup_Window',
'toolbar=no,location=no,directories=no,status=no,menubar=no,
scrollbars=no,resizable=no,copyhistory=no,width=200,height=200,
top=10,left=400')"onMouseOver="window.status='Click me for
sample popup.';return true" onMouseOut="window.status='Try later?'
;return true" >
< img src="" width="" height="" border="0" alt="" style="cursor:hand" >
< /A >



OK and now a bit about Comments
Click here   Comments   ←

This is page 17
 of Learning HTML