Chrome ext,创建JQuery对话框的内容脚本需要忽略iframe [英] Chrome ext , content script that creates JQuery dialog need to ignore iframes

查看:151
本文介绍了Chrome ext,创建JQuery对话框的内容脚本需要忽略iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有简单的chrome扩展,在我打开的每个选项卡上打开JQuery对话框,

问题是当网页中有iframe时,对话框会打开页面中的iframe数量。< br>
i想要避免这种情况,我只需要打开它,每个页面只有一个对话框实例。
如何避免页面中的iframe?

这是我的内容脚本:

i have simple chrome extension that opens JQuery dialog box on each tab i open ,
the problem is when web page has iframe in it , the dialog box opens as many iframes are in the page .
i want to avoid this , all i need it open only and only 1 instance of the Dialog box for each page . how can i avoid the iframes in the page ?
this is my content script :

var layerNode= document.createElement('div');
    layerNode.setAttribute('id','dialog');
    layerNode.setAttribute('title','Basic dialog');
var pNode= document.createElement('p');
    console.log("msg var: "+massage); 
    pNode.innerHTML  = massage;

layerNode.appendChild(pNode);
document.body.appendChild(layerNode);

jQuery("#dialog").dialog({
    autoOpen: true, 
    draggable: true,
    resizable: true,
    height: 'auto',
    width: 500,
    zIndex:3999,
    modal: false,
    open: function(event, ui) {
        $(event.target).parent().css('position','fixed');
        $(event.target).parent().css('top', '5px');
        $(event.target).parent().css('left', '10px');
    }

});


推荐答案

如何用

if(window==window.top) {
   // we're not in an iframe
   // your code goes here
}

这篇关于Chrome ext,创建JQuery对话框的内容脚本需要忽略iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆