Calling a specific id inside a frame

≯℡__Kan透↙ 提交于 2019-12-23 23:28:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!