The page to be opened is passed on by the argument url. Explanationįirst, you open the new window. See below for a far cleaner way of adding popupbehaviour to a link. To create a popup you'll need the following script: This gives several problems, most importantly the confusion over exactly what the URLof the popup is. This site usesthe new system because it's much cleaner than the old one.įinally some notes about writing content directly into the popup. Then a new way of adding popup behaviour to a link. This small window is popularly known as a popup.įirst the basic syntax of how to create a popup, then an explanation of the script, including a table of the most common arguments you can give to a popup and the problem of focusing. This may be what you want, but at other times a small window on top of the largebrowser window is much better. You can add a TARGET="_blank" to the -tag, but thissimply opens a new browser window that completely obscures the old one. When the user clicks ona link, a new window opens and displays a page. Everything from here out is a variation on this theme.Sometimes it's useful to add a popup to your pages. This means that the popup comes to the front every time. When the page in the popup is loaded, this script tells the browser to put the focus on the popup. "popupbasic.html", not the page you are reading right now. "popupbasic.html", so the following code is in So, for example, the link above opens the page Put the following code in the popup page itself. To avoid this problem we have one more piece of code. It stays stubbornly in the background, leaving the user to wonder why the link didn't work. The first time the user clicks the link the popup pops up in front, but if the user then clicks back on the main page again without closing the popup and then clicks on a link to open the popup again, it won't come back to the front. One of the most frustrating problems with popups is that once they are opened they have an annoying tendency to stay in the background. Now we've created and opened the popup, but there's one detail left. If you do, the link will act just like a regular link. Be sure to start the command with return like this:Īnd don't put a space in the page name between the single quotes. OnClick must begin with return or the script won't work. Read This Next Part Or You'll Go Insane Trying to Figure Out Why Your Popup Doesn't WorkĪ small but crucial point is often overlooked. So if you want to name the popup 'stevie' Be sure to put the name in single quotes ( ''). Every popup window should have its own unique name. The second argument of the popup() - 'notes' - indicates name of the popup window. Copy the code as it is into your link, with only a small modification. We've added an additional attribute called The URL of the page being linked to is in the A link like the following would run the script: The most common situation is that the script is run when the user clicks on a link. The script above opens the popup, but something needs to run the script. Under the Hood: Details of the Popup Script for a line-by-line description), and move to the next step. For more details see Under the Hood: Details of the Popup Script.įirst, copy this script into the section of your page:įor now we'll skip the details of how the script works, (see In this section we'll show the code with just the minimal description you need to get it going. The code in this page creates a popup that is opened from a link. Everything for the rest of the turorial is a variation on the theme described here. Different links can target the same popup. The technique described here addresses all the major issues in popups. We'll begin the tutorial by creating a basic popup window.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |