<body onload="document.getElementById('menuTest').style.removeAttribute('display')">
This is the code I'm using. Basically I'm trying to make an element visible only after everything else on the page has loaded. It works fine in IE, but not in Chrome. I don't work with Js muc开发者_如何学Pythonh...but if I remember correctly, is there something finnicky about the getElementById function that I need to do?
<body onload="document.getElementById('menuTest').style.removeProperty('display')">
Test page: http://www.quirksmode.org/dom/tests/cssMisc.html#removeProperty
You do not use remove attribute with styles, you set it to the value needed.
document.getElementById('menuTest').style.display = "block"; //"inline"
If your element has a CSS3 timed transition set on it in CSS, the javascript will also fail even if your code is correct. Because the element is transitioning when the javascript fires, it can not manipulate it in some browsers (Chrome is one). In these cases try delaying the javascript to fire after the transition has had time to finish rendering the element.
精彩评论