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?

Recommended Answers

All 3 Replies

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".

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

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;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.