Internet Explorer cannot open the operation of the website Interrupted, how to fix this error?

This code gives an error in IE

Internet Explorer cannot open the operation of the website Interrupted, how to fix this error?

var tip = "<p>Most computers will open PDF documents "; tip += "automatically, but you may"; tip += "need to download <a title='Link to Adobe website-opens in a new window'"; tip +=" href='http://www.adobe.com/products/acrobat/readstep2.html' target='_blank'>Adobe Reader</a>.</p>"; $(document).ready(function(){ //IF NUMBER OF PDF LINKS IS MORE THAN ZERO INSIDE DIV WITH ID maincontent //THEN THIS WILL PUT TIP PARAGRAPH AS LAST CHILD OF DIV if($("div#maincontent a[href*='/pdf']").length>0){ $("div#maincontent").children(":last-child").after(tip); } }); 

See this page in IE: http://jsbin.com/oliho4

+4
source share
3 answers

It seems obvious to me that you are trying to change an element before the page finishes loading. At least exactly what you do on your demo page. You do not carry the code in $(document).ready() in the same way as in the question

Try this demo site instead of http://jsbin.com/ivuqa , which correctly wraps the corresponding lines in ready()


In addition, using XHTML may cause some problems. In this case, just wrap the offensive part of javascript like this. (CDATA satisfies XML validation, a multi-line javascript comment to hide cdata from a browser that does not understand it and therefore will not be able to run javascript.

 /* <![CDATA[ */ var tip = "<p>Most computers will open PDF documents automatically, but you may need to download <a title='Link to Adobe website-opens in a new window'"; tip +=" href='http://www.adobe.com/products/acrobat/readstep2.html' target='_blank'>Adobe Reader</a>.</p>"; /* ]]> */ 
+4
source

Is this a notorious warning that returns a blank page in IE?

This is a well-known and documented IE question.

This error usually occurs when you try to change the DOM element before the page has finished loading.

Try moving the script to the bottom of the page.

Since you are using a ready-made document, I do not think this is causing the problem. Perhaps this is due to another script on your page?

EDIT:

You can also try to fire your function on the onload body. I just read it here .

EDIT 2: I did not see your link. Jitter is right, you are not using jQuery $(document).ready()

0
source

All Articles