Forum Moderators: mack

Message Too Old, No Replies

Creating a Pop up Window

Can someone give me some advice please!

         

TimmyMagic

5:01 pm on Jul 11, 2006 (gmt 0)

10+ Year Member



Hi,

I want to create a pop up window for my site when a visitor clicks on a certain link. I have managed to find the code from another website and customized it to my needs (i.e. sizing).

Here is the code I have used:

<a href="#" onClick="window.open('helppage.htm', 'Save_Money', 'toolbar=no,resizable=no,scrollbars=yes,width=520,height=350,left=0,top=0');" title="Help Page" class="copylink">Click here if you require help with ordering</a></p>

Now the problem is:

I want to change the 'Save_Money' bit but everytime I do the pop up fails to work.

I also notice that the title for the pop up window is the title from another page in my site where i was testing it. I am clueless as to how to change the title for the pop up. Anyone?

Thanks in advance.

Tim

mack

1:10 am on Jul 12, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Here is some code that should work for you

In your head section place the following code...

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=520,height=350');");
}
// End -->
</script>

Then where you want the link to occur use the following...

<A HREF="javascript:popUp('http://www.example.com')">link text here</A>

Mack.

TimmyMagic

11:42 am on Jul 12, 2006 (gmt 0)

10+ Year Member



Thanks Mack.

I have a few different pop ups for different things, such as help page, discounts page, currency conversion, etc. These are different sizes.

So, rather than include a different bit in the head section for each one, can I use the size/scroll attributes in the body text? And if so, what is the syntax?

Thanks.

Tim

Oliver Henniges

6:23 pm on Jul 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I always thought a popup was something that opened automatically, when you open a page containing it? You said you wanted that window to open on clicking a link: wouldn't a simple a href = ... target = "_blank" do the desired job? But I must admit I do not know how this is handled in tabbed browsing.

TimmyMagic

10:04 pm on Jul 12, 2006 (gmt 0)

10+ Year Member



Well maybe 'pop up' is not the correct word. What I want is a new window opened, but to control the size of the window. I don't want it getting in the way of the buying process!

Tim

tedster

2:00 am on Jul 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For a post with a lot of the "ins and outs" of pop-up javascript, see message #4 here in our Javascript Library:

[webmasterworld.com...]

(The title is CUSTOM SIZE POPUP WINDOWS)