Open Popup 2 JavaScript

  • By: Nate Baldwin
  • For: JavaScript (popup window script)

These instructions explain how to use the scripting from our popular OpenPopup2 GoLive action without using GoLive. To get started, download one of the file archives here:

Expand the archive you just downloaded, and you should find two files inside. The first file, OpenPopup2Lib.js, is a JavaScript file that holds all the functions for using the popup window script. You'll need to link this file to any page that uses the script. To do this, add a JavaScript link in the head section of your page. The syntax should look like this:

<script type="text/javascript" src="OpenPopup2Lib.js"></script>

In the example above, the OpenPopup2Lib.js file is in the same folder as the page that's using it. Otherwise, the value in the scr attribute would need to show the path from your page to the script file instead of just the script file name.

Next, we'll need to make the script function call that's inserted into your page so the script knows what settings to use for your popup window. In your downloaded archive, you should find another file named OpenPopup2Config.html - this is just an HTML file to help you use the script more easily. It does not need to be uploaded to your web server, it's just a tool for you to use on your local computer.

Open the OpenPopup2Config.html file into your web browser. You should end up with a form with all the popup window settings. For now, see the manual included with the Open Popup 2 GoLive action for details on what each of the settings does. The form should very closely match the action's interface. Here is an example of the form page...

Enter your settings, and hit the "build function call" button at the bottom of the form, and your customized code is written into the function call text field below. Copy this text (and leave the form page open just in case you need to copy it again).

Now, return to your HTML page. Make your link that will open the popup window (text or image link) and set the link URL to just be a # sign. Add the generated function call code to an onclick attribute in your link tag. Here is an example:

<a href="#" onclick="paste your code here">Open Popup</a>

Here's what the example link above (to open the configuration page) looks like (though your code should all be on one line):

<a href="#" onclick="return MPOpenPop2('OpenPopup2Config.html','0',true,
'PopUpWin1',true,false,'800',true,'520',false,true,true,'','','','',true,false,false,
false,false,false,'','',false,'','','0','','','');">load Open Popup 2 configuration page</a>

Of course, replace the "paste your code here" part with the code you copied from the configuration form. Then, you popup window should be ready to test. Of course, be sure to upload the OpenPopup2Lib.js file to your web server when you upload your HTML page so the web browser can get to the JavaScript code it needs.

There is a working example of the script on this page (see the link to open the Open Popup 2 configuration page above).