Skip to content Skip to sidebar Skip to footer

Replace Setattribute With Ie Compatible Script

I am trying to create a pop-up message that disables the rest of the screen until you confirm it, only by using CSS and JavaScript (and without the alert function). Although http:/

Solution 1:

Use this as your doctype

<!DOCTYPE html>

and then put this in the head of the document

<metahttp-equiv="X-UA-Compatible"content="IE=edge" />

and then enjoy using setAttribute and a number of other features which this will allow to properly work on IE8+ environments.

Solution 2:

The correct way to set a class in your second example is:

overlaybutton.className = 'overlaybutton';

That will get classes working in IE. As far as deleting elements goes, I'd recommend reformatting your event handling attachment like so:

overlaybutton.onclick = deleteoverlay;

Solution 3:

I have run into this issue as well. If you are able to include jQuery on the site, you can use $('#overlay').attr('class', 'overlay');. jQuery is extremely useful for making cross-browser compatible code.

Post a Comment for "Replace Setattribute With Ie Compatible Script"