Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

attachEvent

Status
Not open for further replies.

hunt00

Technical User
Mar 6, 2005
79
0
0
US
My attachEvent calls a character count function on key up and key down. It slows down IE dramatically, with using up 100% of my cpu.

Does anyone know how could i get over this?

Thanks!
 
document.getElementById("test").contentWindow.document.attachEvent("onkeyup",charCounter);
document.getElementById ("test").contentWindow.document.attachEvent("keydown",charCounter);

 
I havn't seen your full code but im pretty sure you can just
document.attachEvent(someevent).

Seems like you using the document to go the an element to get the content window then the document. Are you using frames?

Also I don't see why this would slow down a broswer, would need to look at your site.

Also attachEvent is an IE only event model. So your script won't work cross browser...
 
Oh yah seems like your attaching the event every time they press a key, that will slow things down:<
 
Thanks very much, Dan, for your help and reminding! It is that i put it on a keypress, above on that calling this attachEvent makes everything slow down. yah, for the firefox, i am using addEventListener.

Have a great weekend!
 
Thank you, j4606 too! (Just refreshed here.) Yes, i have another onkeypress to start this. too many things used together. :) You have a great weekend!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top