Brian Warfield
Brian Warfield

Reputation: 377

Append to Body Issues in IE

I am having issues appending a div to the body tag in IE 9 and down. This is working in Firefox and Chrome.

var currenturl = "the url I am loading";

$(document.body).append('<div id="overlaytransparency"></div><div id="overlaymessage"> <iframe id="overlayframe" src=' + currentUrl + ' scrolling="no" frameborder="0"></iframe></div>');
// ^ This is the line that is erorring

$("#overlaytransparency").show();
$("#overlaymessage").show();

$("#overlaytransparency").click(function () {
    $("#overlaytransparency").hide();
    $("#overlaymessage").hide();
});

    $("#overlayframe").load(currentPath);

I am getting this error in IE:

SCRIPT438: Object doesn't support property or method 'getElementsByTagName'

Thanks in advance for any help.

Upvotes: 1

Views: 2021

Answers (3)

Dasarp
Dasarp

Reputation: 194

i think you are using getElementsByTagName somwhere in your script

see this ref: https://developer.mozilla.org/en/DOM/element.getElementsByTagName

Note: While the W3C specification says elements is a NodeList, this method returns a HTMLCollection both in Gecko and Internet Explorer. Opera returns a NodeList, but with a namedItem method implemented, which makes it similar to a HTMLCollection. As of January 2012, only in WebKit browsers the returned value is a pure NodeList.

Upvotes: 0

Selvakumar Arumugam
Selvakumar Arumugam

Reputation: 79850

Try using $('body') instead of $(document.body).append('<div

$('body').append('<div ...

Upvotes: 1

Etienne Dupuis
Etienne Dupuis

Reputation: 13806

what about

$(document).ready(function() {
    $("body").append();
});

Upvotes: 1

Related Questions