Senior Member
Join Date: Apr 2006
|
Hi again,
I have another query related to JavaScript Basically I have a div that drops-down when the user clicks a button, it's originally set to "display: none;" so when the user clicks the button its then set to "display: block;", and vice versa. What i'd like to do is make this similar to drop-down window's in applications, where if the window is shown and the user clicks somewhere else on the screen, the window is then hidden again. Is there a way of doing this with JavaScript? I'm thinking of using focus() to set the div to "display: none;" again when the user clicks somewhere else on the screen, but i'm not sure on how to go about doing this! Cheers for any help, Steve. Find me on Twitter: @StevenMcLintock |
quote |
25 chars of wasted space.
|
You mean like using onFocus() and onBlur()?
|
quote |
Senior Member
Join Date: Apr 2006
|
Yeah, thats what I mean
Except the opposite if you know what I mean, so when it isn't focused it'll do something. Thanks |
quote |
25 chars of wasted space.
|
Can't you do something likeā¦
<element onBlur="do-whatever-you-want">asdfsdfasdf</element> Shouldn't that do whatever you do when you are no longer focused on an element? |
quote |
Senior Member
Join Date: Apr 2006
|
Just tried that,
It doesn't seem to working, I checked on W3 Schools and the div object isn't supported unfortunately. Thanks anyway though |
quote |
http://ga.rgoyle.com
Join Date: May 2004
Location: In your dock hiding behind your finder icon!
|
If the button that they click on is within the div that drops down, you could use onmouseout="".
|
quote |
Senior Member
Join Date: Apr 2006
|
I got it working ...eventually, it took about 2hr's but I finally worked it out
What I did was use the onclick event to see if the div was shown, if it was and the user wasn't clicking within the div, the div would be hidden. If anyone wants the code, let me know Thanks again, Steve. Find me on Twitter: @StevenMcLintock |
quote |
25 chars of wasted space.
|
Ohhh, I get what you wanted to do now. For some reason I re-read your post at least 3 times and couldn't figure out exactly what you were trying to do, which is why I used the <element> because I didn't know what you were applying it to. Of course reading your original post now is pretty clear. Well anyways good job, sorry I would have helped if I wasn't retarded.
|
quote |
Senior Member
Join Date: Apr 2006
|
Quote:
Thanks for the help though, you at least pointed me in the right path |
|
quote |
Posting Rules | Navigation |
|
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Collapsable menus (showing + hiding DIV layers) | Is it 1981? | Programmer's Nook | 9 | 2007-05-22 15:32 |
CSS: DIV obscured by prior DIV | drewprops | Programmer's Nook | 12 | 2005-12-29 17:59 |
Final Cut Express - How do I add a good Soft Focus? | Gizzer | Genius Bar | 0 | 2005-11-28 08:03 |
Cant hide from dock! | MDK | Genius Bar | 4 | 2005-11-03 02:13 |
Do you hide the Dock? | BlueRabbit | General Discussion | 32 | 2005-04-10 12:47 |