p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   HTML Code Clinic (http://p2p.wrox.com/forumdisplay.php?f=90)
-   -   Pop-up window, on top of webpage (http://p2p.wrox.com/showthread.php?t=3404)

Burton September 2nd, 2003 04:27 AM

Pop-up window, on top of webpage
 
I have a small "thumb" picture on a htm-page and when one clicks on the image i want a new window opening of that picture in full size (maximized).

Here I have an example of what it COULD (mustn't be same) look like:

<body>
 <p>
<a href="PICTURE.jpg" OnClick="window.open('PICTURE.jpg', 'big', 'fullscreen=yes')"><img border="0" src="PICTURE.jpg" width="172" height="129">
 </p>
 </a>
</body>

The only problem i have here is that the image opens twice; once redirected (not needed), and once in new window (correct). Also, I need a 'close window' link to go back to previous page.


meow September 2nd, 2003 04:36 AM

Hi :)

You need to add "return false" at the end of the onclick. This will kill the link event and stop the link from opening in the primary window too.

<a href="" onclick="window.open(); return false">

To create a close button you could use window.close().

(o<
//\ =^..^=

Burton September 2nd, 2003 10:49 AM

Before you send your reply, test the "Post New Reply" on this site - that's what I would like to have!"

Hi :D

The return false was the solution, thx a lot!

Now for the window.close, what do I need? Something like this':
"javascript:window.close()">Close Window<

Here's the body:

<body>
<p>
<a href="PICTURE.jpg" OnClick="window.open('PICTURE.jpg', 'big', 'fullscreen=yes'); return false"><img border="0" src="PICTURE.jpg" width="172" height="129">
</a>
</body>


Burton September 2nd, 2003 10:52 AM

*ooops* I meant PREVIEW your reply [:I]


meow September 3rd, 2003 03:55 AM

Why should I preview? Did I write something funny that I don't see myself? [:o)]

You use it in an event handler in the same way as the window.open(). If you want it to work in Ye Old Browsers like Nav 4 it needs to be in a link. If that doesn't matter you don't have to use a link.

For example:
<a href="#" onclick="window.close()"><img src="closepic.gif"></a>

(o<
//\ =^..^=

Burton September 3rd, 2003 04:29 AM


Hi Meow...[:0]

No not at all, your posts are great! The PREVIEW is just an example of how I would like the CLOSE WINDOW link to be.

Can you please copy+paste the body i posted previously and insert the close.window() in the right place for me.... i know i am terrible, a real novice [xx(]

I tried it myself, but the 'close window' appears on the main page, and not in the pop-up window. Do I not have to include it within the brackets of OnClick below to be in that window?:
OnClick="window.open('PICTURE.jpg', 'big', 'fullscreen=yes'); return false">

Sorry for the inconvenience and would appreciate your answer mate...



All times are GMT -4. The time now is 06:53 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.