Pop Up page HELP

Any problem with javascript can be discussed here.
Post Reply
uz
Posts: 140
Joined: Sat Dec 24, 2005 5:32 pm

Pop Up page HELP

Post by uz »

I want to create a page where only the content will be displayed in the window without panels, icons, just window like in pop-up adverts
when user **** the link the page in more detail should appear


eselooo
Posts: 21
Joined: Fri Jun 09, 2006 7:20 am

Post by eselooo »

We'll begin the tutorial by creating a basic popup window. The technique described here addresses all the major issues in popups. The popup always comes to the front. Different links can target the same popup. The code is simple and easily modified. Everything for the rest of the turorial is a variation on the theme described here. The code in this page creates a popup that is opened from a link. In this section we'll show the code with just the minimal description you need to get it going.
First, copy this script into the <HEAD> section of your page:

Code: Select all

<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=400,height=200,scrollbars=yes');
return false;
}
//-->
</SCRIPT>
For now we'll skip the details of how the script works, and move to the next step. The script above opens the popup, but something needs to run the script. The most common situation is that the script is run when the user **** on a link. A link like the following would run the script:

Code: Select all

[url=popupbasic.html]my popup[/url]
Most of the link is as usual. The URL of the page being linked to is in the HREF attribute. We've added an additional attribute called ****. Copy the code as it is into your link, with only a small modification. The second argument of the popup() -- 'notes' -- indicates name of the popup window. Every popup window should have its own unique name. Be sure to put the name in single quotes (''). So if you want to name the popup 'stevie' then this would be the code:

Code: Select all

[url=popupbasic.html]my popup[/url]
A small but crucial point is often overlooked. The command in **** must begin with return or the script won't work. Be sure to start the command with return like this:

Code: Select all

****="return popup(this, 'notes')"
And don't put a space in the page name between the single quotes. If you do, the link will act just like a regular link.
Now we've created and opened the popup, but there's one detail left. One of the most frustrating problems with popups is that once they are opened they have an annoying tendency to stay in the background. The first time the user **** the link the popup pops up in front, but if the user then **** back on the main page again without closing the popup and then **** on a link to open the popup again, it won't come back to the front. It stays stubbornly in the background, leaving the user to wonder why the link didn't work.

To avoid this problem we have one more piece of code. This code does not go in the main page. Put the following code in the popup page itself. So, for example, the link above opens the page "popupbasic.html", so the following code is in "popupbasic.html", not the page you are reading right now.

Code: Select all

<SCRIPT TYPE="text/javascript">
<!--
window.focus();
//-->
</SCRIPT>
When the page in the popup is loaded, this script tells the browser to put the focus on the popup. This means that the popup comes to the front every time.

That's all the basic pieces to a popup. Everything from here out is a variation on this theme.
Nothing to be proudly!
Post Reply