Scripts: Javascript :: Popup windows :: Library Article #27
Developer's Section
Create a Simple Popup Window for your website By: Erobo Team Member
|
Hire a Developer for Related Work / Installation | $55 hr
|
|
Rating: | Rate It:
|
Average Votes: (3153)
|
Favorites:
|
|
|
|
Learn how to create a custom popup window for your website.
The method described below displayPopup() can be used to create a popup window with the dimensions that you want. Also this function can be modified to write html code inside of it. If you need to use this function to create a printer friendly version of the page, you need to make sure you call window.document.close() before calling window.print(), otherwise the popup window won't print. In this case calling vWinPht.document.close(), before calling the method to print the popup window would work.
Example:
Open PopUp
Code:
| Code Snippet 1 |
|
|
<script type="text/javascript">
function displayPopup(url, winName, dim1, dim2) {
dim1 = dim1 + 20;
dim2 = dim2 + 20;
var myparam = "width=" + dim1 + ",height=" + dim2 +
",status=no,resizable=no,top=200,left=200";
vWinPht = window.open(url, winName, myparam);
vWinPht.opener = self;
// can write html to it using the following code below:
//vWinPht.document.write("<img src=\"..\/images\/lg\/animage.jpg\">");
//vWinPht.document.write("<input type='button' ");
//vWinPht.document.write(" value=' Print this page '");
//vWinPht.document.write(" id='btntoprint' />");
//close the window object before calling print
//vWinPht.document.close();
//add method for printing popup window
//vWinPht.document.getElementById("btntoprint").onclick = function() {
// vWinPht.print();
//}
}
</script>
|
|
|
See other Scripts in Popup windows |
Submit Your Scripts: |
System Message:
- Your Javascript script has been sent. Please allow 48 hours for processing.
|
If you would like to have your Javascripts published in this section please fill out the form below: |