Cindy Cindy - 1 year ago 93
Javascript Question

Show more than 10,000 characters in a JavaScript Alert

Possible Duplicate:

javascript object max size limit at 10000 chars

I want to check whether html source contains a specified string, but I'm only getting 10,000 characters (in alert box)

var str=document.documentElement.innerHTML;
if(str.indexOf("abcxyz") !== -1)

How can I fix that?

Answer Source

If you need to display a huge string in alert boxes, I guess you could split it into 10,000-character chunks and display them in order. Alternatively, just use console.log to print it out.

And is there a better way to detect a "onClick" event?

Better than what? JavaScript events will bubble up to the top containing element (unless some element in the chain calls stopPropagation()), so an easy way to detect click events would be to attach a click handler to document.body:

document.body.onclick = function() { alert('Click!'); }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download