I have the code below to get an element by ID. How to change this code to work cross-browser? Please help me.
var home = window.document.frames["ifrmmain"].document.frames["ifrmchild"].document.getEleme开发者_Python百科ntById("tdHome");
var homeLink = top.document.frames["ifrmmain"].tdHomeLink;
Put id
attributes on your iframe
tags, and replace document
with contentDocument
when accessing the document of a frame. For example:
var home = document.getElementById('ifrmmain').contentDocument.getElementById('ifrmchild').contentDocument.getElementById("tdHome");
window.frames[0].document.getElementById('btnSave').click();
or
window.frames['iframename'].document.getElementById('btnSave').click();
精彩评论