Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Old 11-22-2006, 02:40 PM Image Popups
Extreme Talker

Posts: 161
Trades: 0
Hello i have a site that has small images and i want it that when click on a image a popup window will open and then you can close it when finshed.

I hope was hoping to do this in HTML or CSS but if i can't please point me in the right places please.

Thanks
afcbob is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-22-2006, 03:13 PM Re: Image Popups
Mooofasa's Avatar
Defies a Status

Posts: 1,611
Name: Michael (mik) Land
Location: England
Trades: 0
You'll need to use Javascript to firstly open a page, and then another script (or snippet) to close the window.
__________________

Please login or register to view this content. Registration is FREE
- Tumblog with thoughts, quotes, links, videos, images and my creations.

Please login or register to view this content. Registration is FREE
- The best free web browser.

Please login or register to view this content. Registration is FREE
- Firefox is now Firefail.
Mooofasa is offline
Reply With Quote
View Public Profile Visit Mooofasa's homepage!
 
Old 11-22-2006, 03:55 PM Re: Image Popups
Extreme Talker

Posts: 161
Trades: 0
Do you no of any java script already coded that i could use just to get it started. As i not started learning java yet.
afcbob is offline
Reply With Quote
View Public Profile
 
Old 11-22-2006, 04:37 PM Re: Image Popups
Mooofasa's Avatar
Defies a Status

Posts: 1,611
Name: Michael (mik) Land
Location: England
Trades: 0
Java and Javascript are completely different things.

Basically, when you click on one of your images, a new page is displayed showing the larger version and the close button. This page that is opened is just another HTML file.

Use the window.open method in the onClick within a img tag.
Code:
window.open("http://www.domain.com/popup.html","Photograph","resizable=1,width=200,height=100");
With the window.open() method, you have several properties that can be specified, such as window title, whether it's resizable, etc. They are all self explanatory.

Then, with the HTML file that is to be pop-uped, you need to add a self.close() method.

This can be done with any element, however it is easily accomplished with the <a> tag:
HTML Code:
 <a href="javascript: self.close()" title="Close current window">Close</a>
__________________

Please login or register to view this content. Registration is FREE
- Tumblog with thoughts, quotes, links, videos, images and my creations.

Please login or register to view this content. Registration is FREE
- The best free web browser.

Please login or register to view this content. Registration is FREE
- Firefox is now Firefail.
Mooofasa is offline
Reply With Quote
View Public Profile Visit Mooofasa's homepage!
 
Old 11-22-2006, 06:06 PM Re: Image Popups
Extreme Talker

Posts: 161
Trades: 0
Ok this is what i have is this the best way todo it.

Just two things i would like changed.

1,Can i put all the javascript on its on file as i have lots of images and code would get very long.

2,when you the mouse does not change to let you no it can be clicked how do i do this.

the images is on the main page the 2 images can be clicked on:
http://www.marinetreat.info
afcbob is offline
Reply With Quote
View Public Profile
 
Old 11-23-2006, 03:05 PM Re: Image Popups
Mooofasa's Avatar
Defies a Status

Posts: 1,611
Name: Michael (mik) Land
Location: England
Trades: 0
HTML Code:
<a href="window.open("http://www.domain.com/popup.html","Photograph","resizable=1,width=200,height=100");" style="cursor: pointer;" title="View Photograph"><img></a>
The style="cursor: pointer;" will make the hand appear on hover (if it doesn't then set a:hover{cursorointer;} in the CSS file / header.

As the address for the image changes, putting the Javascript in it's own file would be pointless.

If you just want the image to open in a new window, without a "Close Window" button, simply use the <a> and target="_blank". The Javascript window.open is basically for making pop-up windows. But with your current doctype, this isn't applicable.
__________________

Please login or register to view this content. Registration is FREE
- Tumblog with thoughts, quotes, links, videos, images and my creations.

Please login or register to view this content. Registration is FREE
- The best free web browser.

Please login or register to view this content. Registration is FREE
- Firefox is now Firefail.

Last edited by Mooofasa; 11-23-2006 at 03:07 PM..
Mooofasa is offline
Reply With Quote
View Public Profile Visit Mooofasa's homepage!
 
Reply     « Reply to Image Popups
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22744 seconds with 12 queries