This code giving error in IE
Internet Explorer Cannot Open the Internet Site Operation Aborted, 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
To me it seems obvious that you try to modify some element before the page has finished loading. At least that’s exactly what you do on your demo page. You don’t wrap the code in
$(document).ready()as you did in the questionTry this demo-site instead http://jsbin.com/ivuqa which correctly wraps the relevant lines in
ready()Additionally there might be some problems when using XHTML. In that case just wrap the offending javascript part like this. (CDATA to satisfy the XML validation, javascript multiline comment to hide the the cdata from browser which don’t understand it and thus would fail to run the javascript.