hide elements in an iframe from the parent when the iframe has no id

ぐ巨炮叔叔 提交于 2019-12-13 06:40:30

问题


The url is http://oxfordgenetics.com/plasmid-builder and the iframe comes from the "product details" link on each builder group. What I need to do is hide some of the elements in the shadowbox that appears when this link is clicked.

I have tried all of the usual remedies (both jQuery and js) without success as most of them latch onto the iframe using its ID which doesn't exist here.

Same domain of course.


回答1:


You know the iframe will be in the shadowbox, which has an id of sbox-content. So this should work:

var $iframe = jQuery('#sbox-content iframe')



回答2:


I got around it by having the code below test if it was a 'modal' box or not with an arbitrary ID that was only in the 'modal' window:

var element = document.getElementById('system-message-container'); 
if (typeof(element) != 'undefined' && element != null)
{
       document.getElementById('cartarea').style.display='none';
}


来源:https://stackoverflow.com/questions/19465655/hide-elements-in-an-iframe-from-the-parent-when-the-iframe-has-no-id

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