Calling a specific id inside a frame

2019-07-11 13:02发布

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条回答
爷、活的狠高调
2楼-- · 2019-07-11 13:21

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)

查看更多
登录 后发表回答