问题
I have a iframe tag in mainpage.html, that iframe calls back.html..
is there any way to call only the specific ids in back.html for display in iframe..
Detail: I have 25x25 table in back.html. initially iframe shows all 625 cells minimised. each cell has a unique id. can i call a specific cell only to display(original size) inside iframe.
or is there any other way to go around it.. please specify
回答1:
Try this code:
var iframe = document.getElementById('your-iframe-ID'),
/* or other kind of reference to the iframe DOM node */
iframeDoc = ((!!iframe['contentDocument'])
? iframe.contentDocument
: iframe.contentWindow.document),
cell = iframeDoc.getElementById('your-cell-ID');
/* this is a reference to cell inside the iframe */
Of course I assume that mainpage.html and back.html are in the same domain (for the same-origin policy)
来源:https://stackoverflow.com/questions/8710100/calling-a-specific-id-inside-a-frame