Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show more than 10,000 characters in a JavaScript Alert [duplicate]

Tags:

javascript

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)
{
  alert(str);
}

How can I fix that?

like image 222
Cindy Avatar asked Jul 14 '26 03:07

Cindy


1 Answers

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!'); }
like image 187
Mihai Avatar answered Jul 15 '26 18:07

Mihai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!