473,379 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

JavaScript Event "onOffClick"

164 Expert 100+
I've done some rudementary searching for a topic that would lead me to a good solution, but I have not found any so far. I was hoping Bytes might lead me to glory!


I built my own "pop up calendar" script.

It creates a table that has hyperlinks inside cells which, once clicked, will populate a textbox with a preformatted date.

It positions the table absolutely at the mouse coordinates when a particular image is clicked.

The goal I am now trying to accomplish is: when the table is showing on the screen (i.e. the table element exists in the DOM) should the user click on anything BUT the table, the table element is destroyed).

I've tried using on onBlur() on the table, and automatically focus()'ing on the table at its creation. This works until the user tries to click the hyperlinks in the cells, at which point the onBlur fires before the click event for the hyperlink. So, no bueno.

I tried creating an event listener at the document level which listens for a click event on anything that isn't the table (or the original element that spawns the table)... but the problem with that is if the user tries to click on the links which scroll between months in my calendar, it'll disappear!

Can anyone think of a simple solution that I am missing?
Mar 27 '10 #1
1 1727
Nicodemas
164 Expert 100+
A simple solution was not found. I ended up writing a while loop that tested the parentNode of the click event source element until it either found the calendar table or it found the BODY/HTML/undefined.

If it found the BODY/HTML/undefined, it removed the calendar element from the DOM; otherwise, the loop was exited with a break statement.
Mar 29 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dan | last post by:
In response to... DSAsteve@aol.com 6/20/2003 post wc_fl@NOSPAM.hotmail.com 3/26/2003 post ....The javascript event calendar found at http://www.scriptcalendar.com satsifies both...
19
by: Sjaakie Helderhorst | last post by:
Hello, I need to add a Javascript event (onClick) to a servercontrol (asp:checkbox). Checkbox is named 'cbDoMail'. Assumed that 'cbDoMail.Attributes.Add("onClick", "doJavascriptThing()") would do...
8
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"...
1
by: sshan | last post by:
I need to invoke javascript event onKeyDown, which should get invoked when we press any key from anywhere of the page. currently I am callin like this: <head> <script type="text/javascript">...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.