How do i make a Pop Up?

senne

Registered
What's the HTML-code for making a Pop Up?

And how do i set a window for not displaying the Adressbar, Favouritebar, Buttonbar, Statusbar...?


Thanks already!
 
You will be using Javascript (<script> tags). My example shows how to open a picture called senne.jpg, size 496x496, placed in images/ folder, in a popup with no toolbar etc.

Placed on top of page:

Code:
<script type="text/javascript"><!--
 function popwin(imgurl, imgwidth, imgheight)
  {
   imgpop = window.open("", "imgpop", "resizable=no,width=" + imgwidth + ",height=" + imgheight + ",scrollbars=no");
   imgpop.document.write("<HTML>\n<HEAD><TITLE>" + imgurl + "</TITLE></HEAD>\n");
   imgpop.document.write("<BODY topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>\n");
   imgpop.document.write("\t<a href='javascript: window.close()'><IMG SRC='" + imgurl + "' border='0'></a>\n");
   imgpop.document.write("</BODY>\n</HTML>\n");
	
  return false;
 }

// --></script>

Now in your HTML page text:

Code:
<a onclick="return popwin('images/senne.jpg', '496', '496');">Click me to see senne.jpg picture</a>

Example of this code in action: my doodle page.
 
You can force pop-ups in Safari, even when disabled. :p

But I use Chimera / Camino, so I just refuse to see them.
 
Originally posted by AppMan
People who put pop up ads on their web-sites are very bad people.


i don't use it for commercial purpose! It's rather skilful. I use it for the news of my site, so the people stay up to date ;) I'm not a bad boy! :D
 
Originally posted by AppMan
People who put pop up ads on their web-sites are very bad people.

If you knew HTML coding, you'd realize the popup code I've given is not an <body on load> popup (ie a popup that opens with your page), but a popup you trigger voluntarily by clicking a link.

Look at my design page: to see a picture at full size, you click a link: the picture opens in a smaller window. Nothing forced, on the contrary, this popup method serves the user a lot.

And yes, those popups work even if adblocking is on. For the very simple reason that they are not considered as ads, as they don't open at page launch but on user purpose.
 
Sorry to disturb you again, but i've got another question.. Hey, what's a forum for? :)

What's the code for a HTML-page to pop up with a click? Not just an image, but a whole page (also without the buttons/adressbar/statusbar/.... ) ?
 
Take a close look at my code: it's a HTML code.
Just get the picture arguments out and add some text in my Java function and you're done.

Code will thus begin by: function popwin(window_title,window_width, window_height) etc...
 
Also you do not always need to write the body of the popup window in JavaScript. The first parameter of the window.open() method can be the URL of the HTML (or JSP or whatever) page that you want to load into the window.

hth,
bear

People who assume all popups are used for ads obviously don't write web applications.
 
Originally posted by bootedbear
The first parameter of the window.open() method can be the URL of the HTML (or JSP or whatever) page that you want to load into the window.


I would not use the window.open() function simply to open a URL in a new window. I'd use the target=blank method to do so:
Code:
<a href="www.thinkhybrid.fr.st" target="_blank">Click here to open my homepage in a new standard window !</a>

Unless you need to resize or modify the popup, the window.open() method is useless in this case. But you've got a point, it works for URLs too.
 
I would not use the window.open() function simply to open a URL in a new window. I'd use the target=blank method to do so:

Yes, also a useful (and under-used, imho) technique to open another full browser window. But window.open() is necessary if control over the window attributes is required.

hth,
bear
 
Back
Top