943,964 Members | Top Members by Rank

Ad:
Sep 6th, 2005
0

Onclick questions

Expand Post »
Ive been working on adding an onclick feature to my page. i have a gallery that when you click on a picture it opens to a sized window, what i would like it to then do is close if someone viewing it clicks on the image. Ive tried to artisticly borrow it from other sites but i can never get it to work right or they have some weird script i dont understand.

if someone could help me out or point me in the right direction i would be greatfull also any one who could direct me on finding what other options the onclick feature provides i would also be greatfull.

thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
nspireing is offline Offline
45 posts
since Nov 2004
Sep 6th, 2005
0

Re: Onclick questions

HTML and CSS Syntax (Toggle Plain Text)
  1. <b>My Onclick Demo</b><a href="http://nerdlib.com/" target="_blank" onClick="window.open('http://nerdlib.com', 'myWin2', 'toolbar=no, directories=no, location=no, status=yes, menubar=no, resizable=no, scrollbars=no, width=400, height=390'); return false">Nerd Lib Software Labs</a>
Reputation Points: 12
Solved Threads: 19
Posting Pro
techniner is offline Offline
521 posts
since May 2005
Sep 6th, 2005
0

Re: Onclick questions

I think he's actually asking for a way to CLOSE the opened window. You can use the "self.close()" method in the opened window. I would not tie that to the click method of the displayed image, however. Display a "close me" button, instead.

In actuality, though, this is completely unnecessary. Everyone understands how to close an open window; there is no need to code an extraneous control.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Sep 6th, 2005
0

Re: Onclick questions

the thing i was going for here is protecting the images yes i understand anyone who wants them will get them one way or another but i plan on making it as annoying as i can. so my hope was to have a user click on the window and the page will close. ive tried going to a few pages that i know do this and they have some odd script that dosent exist on the same page so i cannot 'ahem' borrow it.

the code from techniner is a little more messy than the one im using but all in all its about the same i just need the extera step. thanks for posting though.
Reputation Points: 10
Solved Threads: 0
Light Poster
nspireing is offline Offline
45 posts
since Nov 2004
Sep 6th, 2005
0

Re: Onclick questions

Wrap the img tag in the new window with an anchor declaration. Code the onclick handler for the anchor, using self.close:

HTML and CSS Syntax (Toggle Plain Text)
  1. <a href="javascript:self.close();"><img src="http://www.tgreer.com/tgroup.png"></a>
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Sep 7th, 2005
0

Re: Onclick questions

i tried using that and i cannot get it to work in firefox and i tried it in IE 6 and it kept erroring then finally worked.

(did i ever mention how much i hate sp2???)
Reputation Points: 10
Solved Threads: 0
Light Poster
nspireing is offline Offline
45 posts
since Nov 2004
Sep 7th, 2005
0

Re: Onclick questions

Make sure you do your testing from a web server, as opposed to local files.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Sep 8th, 2005
0

Re: Onclick questions

That code works fine for me in FireFox and IE6 with XP SP2
Reputation Points: 12
Solved Threads: 19
Posting Pro
techniner is offline Offline
521 posts
since May 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: The new "haslayout" IE CSS feature - Explained
Next Thread in HTML and CSS Forum Timeline: <Base> tags in Body? - Whatchout for IE7!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC