| | |
Onclick questions
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2004
Posts: 44
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: May 2005
Posts: 514
Reputation:
Solved Threads: 19
HTML and CSS Syntax (Toggle Plain Text)
<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>
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
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.
In actuality, though, this is completely unnecessary. Everyone understands how to close an open window; there is no need to code an extraneous control.
•
•
Join Date: Nov 2004
Posts: 44
Reputation:
Solved Threads: 0
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.
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.
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
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)
<a href="javascript:self.close();"><img src="http://www.tgreer.com/tgroup.png"></a>
•
•
Join Date: May 2005
Posts: 514
Reputation:
Solved Threads: 19
That code works fine for me in FireFox and IE6 with XP SP2
![]() |
Similar Threads
- changing from onclick to onsubmit? possible? (JavaScript / DHTML / AJAX)
- Tutorials & Code Submissions - Questions? (DaniWeb Community Feedback)
Other Threads in the HTML and CSS Forum
- Previous Thread: how to validate checkbox with different names?
- Next Thread: <Base> tags in Body? - Whatchout for IE7!
| Thread Tools | Search this Thread |
Tag cloud for HTML and CSS
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity create css design development displayimageinsteadofflash dreamweaver drupal emailmarketing epilepsy explorer firefox flash font fonts form format google griefers hackers hitcounter hover html ide ie7 ie8 iframe image images internet internetexplorer intranet iphone javascript jpeg layout macbook maps marketshare microsoft mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization perl pnginie6 positioning problem scroll seo shopping studio swf swf. templates textcolor theme timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7 wordpress xml xsl






