Can anyone please let me know what attributes I should use instead of these (which I have used for Internet Explorer) to work in chrome or firefox:
For changing visibility of an element:
obj.style.visibility = 'visible/hidden';
For getting the element:
document.getElementById("id");
For writing a string value into an element:
obj.innerHTML = "....";
To set or retrieve the left position of an object:
obj.style.posLeft/posTop = ...;
Or can anyone please suggest some article on browser compatibility?
3 Answers 3
obj.style.posLeft/posTop should be obj.style.left/top, and their value must always include a unit. Other than that, the snippets you showed should work on all browsers. Also, those positioning properties only work for elements that are not "statically" positioned, i.e., elements with position: absolute, position: relative or position: fixed.
2 Comments
All are supported. You can check supported browsers at w3c. For example for posLeft http://www.w3schools.com/js/js_htmldom.asp
Comments
answers above are correct, but i'd like to add, that you'd better use any popular javascript framework to avoid things like:
window.screenY, window.screenX (for Firefox)
window.screenTop, window.screenLeft (for IE and Opera)
and other differences you will run into later
ps. http://caniuse.com/ is good too
Comments
Explore related questions
See similar questions with these tags.
obj.style.left/obj.style.top = '10px';(must add px (or other unit) otherwise it won't work)