Javasript popup window article
In this tutorial I will show you how to create a layer based popup window withJavaScript.
Layer based Javascript popup window
Creating a popup window is maybe one of the most often used Javascript use case.However a traditional popup window is not the best choice nowadays as it is almostalways blocked by browsers. Besides this sometimes the site design requires a better alternative.To solve the above mentioned problems we can imitate popup windows using someHTML div tags, a bit of CSS and a some lines of JavaScript code.
The concept:
Let's put every html code inside a special div block and hide it by default. For a specifieduser action - like mouse over or click events - we will display the hidden layer in fron of the others. Besides this we add some exiting function to the popup window to hide it if itis not more required.
The implementation:
As I mentioned before we will create a special div block and put our popup windowcontent into this block. Let's call it to popupcontent and use this as id to identify the popup block like this:<div id="popupcontent">This is a popup window!</div>
The popup window CSS:
Let's create the relevant CSS code which format the popup window. The most important parameters are the overflow, visibility and position. I have added more parameters, just tomake the popup window more attractive. So the CSS code for the popup window look like this:
Leave a Comment