javascript - Unexpected call to method or property access - appendChild() -
i have created bookmarklet executes below code, adding css styling page. works on tried sites in chrome , firefox, fails sites on ie. it's same sites fail.
the fourth line fails "unexpected call method or property access" sites, on ie.
var head = document.getelementsbytagname('head')[0]; var style = document.createelement('style'); style.type = 'text/css'; style.appendchild(document.createtextnode("")); head.appendchild(style);
two sites fail on ie 10:
http://www.momswhothink.com/cake-recipes/banana-cake-recipe.html http://www.bakerella.com/
i think problem line:
style.appendchild(document.createtextnode(""));
here inserting text node
style
element, according html specification not allowed, unless specify scoped
attribute on style.
check specification of style here (text node
flow content).
you can find ways create style element in crossbrowser way here.
Comments
Post a Comment