views:

71

answers:

1

I inherited a piece of code that uses document.write to insert a certain div when the code is encountered. Unfortunately, this code is causing issues in IE where the code fails.

Is there a way around this to insert a div on the page without it? I can't make a big change since this code is currently used by many clients(it's like google adsense kind of thing).

Is there an alternative to document.write - I don't have a way to capture a div on the page since it's something plugged in by anyone.

A: 

Something like this may work

var newDiv = document.createElement('div');
document.getElementById('parentElementId').appendChild(newDiv);
Claudio Redi
can't do this - the element is added dynamically to a user's page,so no div is ever known to be on the page.
Dhana