![]() If you want to see a working example of this code then check out the Pop-up Windows Examples Page. Var linkElems = document.getElementsByTagName('a'),i ![]() Attach the onclick event to all your links that have the specified CSS class names Newwindow=window.open(popurl,popupName,eval(popupSpecs)) Opens the pop-up window according to the specified specs Var popupName = Math.floor(Math.random()*10000001) Create a "unique" name for the window using a random number figure out what popup size, etc to apply to the click When the link is clicked, this event handler function is triggered which creates the pop-up windows Set your 3 basic sizes and other options for the class names above - create more if needed initialize the 3 popup css class names - create more if needed Step 2: Add this javascript to the head or preferably to an external javascript fileĬlick on the code to select it all and then do your CTRL+C copy magic. You can use popup1, popup2, or popup3 for class names as in this html link code example below: Javascript Popup Step 1: Add the css class to any link that you want to act as a pop-up I've configured the code for 3 different size pop-ups but you can add more or change the existing ones easily. We will keep the html and the javascript separate which is a cleaner approach and in a practical sense will make things much easier for you to maintain going forward. We'll use a more modern approach and avoid putting the javascript code into the body of your HTML document. Also jQuery does a great job of reducing the cross-browser problems that often arise when using javascript.īut if you can't use jQuery to integrate the code for pop-up window functionality into your website then use the javascript code below. If you can, then use the jQuery popup code instead - it's lot more compact and sturdy. If you're in a hurry and quickly have to create a pop-up window for a single link then use the pop-up window generator. Create Pop-up Windows How to Use Javascript to Create Popup Windows
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |