Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

22 of 48 people (46%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

With onclick and ondblclick registered to a div/table, I can rarely get ondblclick to fire!

Apr 6th, 2008 18:43
ha mo, Colin Fraser, neko noguchi,


Firstly, registering both events to fire on the same handler is always
going to be risky. the vagaries of the operating system, the different
speeds at which people click and double click will always cause some
problems. This is so obvious however, that I suspect that this is not
the question you are asking. 
The question you are asking, I think, may be "why can I not get events
to properly fire inside the table that lies in a div." You have
constructed the div properly, the table too, but it still causes
problems, and is it the table that is causing the problem? Happens all
the time with tables, there is something about tables and JavaScript
that just does not work properly. I have no clear idea why, ever noticce
how technical manuals and books tend not to say a lot about tables?
Anyway, this is not being overly helpful, but the answer appears to be
somewhat simple, create your table dynamically. 
<div id="newdiv">
<script>
document.write("table width='50%' name="mytable">
document.write("<tr><td>Data</td><td>1st image rollover</td><td><a
href='javascript:void()' onClick='doThis()' ondblClick='doThat()''><img
src='image1.gif'</a></td></tr>");
document.write("<tr><td>Data</td><td>2nd image rollover</td><td><img
src='image2.gif'</td></tr>");
document.write("</table>);
</script>
</div>
whatever code you want, place inside the script in the appropriate
places, dont ask me why though, I know this works. More scripts work
inside tables that are dynamically created then those that are not. Just
make sure of your double and single quote marks. 
Good luck.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com