0

e.g.

<table><tr><td onclick='ChgText()'>test</td></tr></table>

now "test" are results from mysql. So i want all those results to load before onclick on the column can be enabled. This is because if i press onclick too quickly, the function doesn't capture certain information.

any help?

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by fxm
0

If you have only that one event, this

<td onclick='if (document.readyState != "complete") return false; ChgText()'>

should solve the problem.

If you have many onclick= calls to ChgText(), leave them all as they are and put a .readyState test at the beginning of that function instead.

If you have many onclick= calls to various functions, leave all the onclick= and function() code alone and completely disable document.onclick until readyState == "complete".

Edited by fxm: n/a

0

If you have only that one event, this

<td onclick='if (document.readyState != "complete") return false; ChgText()'>

should solve the problem.

If you have many onclick= calls to ChgText(), leave them all as they are and put a .readyState test at the beginning of that function instead.

If you have many onclick= calls to various functions, leave all the onclick= and function() code alone and completely disable document.onclick until readyState == "complete".

i tried this but it's not working. when the page loads onclick doesn't work

if (document.readyState != "complete")
{document.onclick = null;
	} else {}

... thx btw

Edited by MDanz: n/a

0

That's because your code is working too well :)

The optimal fix depends on when and how that code is being executed. If it is in the function ChgText(), then either

if (document.readyState != "complete") return

or

if (document.readyState != "complete") return false

may get the result you want without obliterating the document.onclick handler.

Otherwise you need to reverse that obliteration at an appropriate time, like so

function reEnable() {return true}
document.onclick=reEnable;

Edited by fxm: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.