English 中文(简体)
DOM
原标题:Access NPAPI from pages DOM

I m 试图推翻网站kitNoifications.create Notetification的缺省功能,并通过一个能够在OMS网页上添加一个文字的 Chrome号。 问题 现在,我需要从OM网页上查阅chrome.extension.sendRequest,以便把我的要求推向国家促进平等论坛I的网页。 此前,在执行内容说明时,我每个网页上都放下了嵌入物体,但认为如果国家扫盲计划包含在范围内,而不在每一页上注入,它就会更加有效(和安全)。

if (window.webkitNotifications)
{
    (function()
    {
        window.webkitNotifications.originalCreateNotification = window.webkitNotifications.createNotification;
        window.webkitNotifications.createNotification = function (iconUrl, title, body) {
            var n = window.webkitNotifications.originalCreateNotification(iconUrl, title, body);
            n.original_show = n.show;
            n.show = function ()
            {
                console.log("Chrome object", chrome);
                console.log("Chrome.extension object", chrome.extension);
                chrome.extension.sendRequest({ title  : title,  body  : body,  icon  : iconUrl});
            }
            return n;
        }
    })();
}

这就是在人力部中作为文字内容注入的内容。 背景文件如下:

<embed type="application/x-npapiplugz" id="plugz">
<script>
var osd = document.getElementById( plugz );

function processReq(req, sender, callback)
{
    osd.notify(req.title, req.body, req.image);

    console.log("NOTIFY!", req.title, req.body, req.image);
};

chrome.extension.onRequest.addListener(processReq);
</script>
问题回答

如果您的延期包括一个新人民党的花,,它就不再安全: 但是,你的正确性是,不要让每一个网页都能查阅假想,而是让你延期。 我假设你知道“公共”财产,其中具体说明贵方的原始资料能否通过定期的网页查阅,这一违约是假的。

下面,我将解释一下你的问题,也就是从OMP网页问题看,从现在到NPAPI,这基本上是为什么你的通知能够查阅你的内容说明或延伸页。

如你所知,查阅内容文字和网页是相互隔绝的。 他们分享的唯一东西是OM。 如果你希望通知优先于你的内容说明,你必须在共享的OMS内这样做。 http://code.google.com/chrome/extensions/content_scripts.html#host-page- Communication”rel=“nofollow” 内容文字文件中与插入网页的链接。

你们可以这样做,你们的内容文字就从你们的OMOM那里收集的数据,例如:

var exportEvent = document.createEvent( Event );
exportEvent.initEvent( notificationCallback , true, true);
window.webkitNotifications.createNotification = function (iconUrl, title, body) {
  var n = window.webkitNotifications.createNotification(iconUrl, title, body);
  n.show = function() {
    var data = JSON.stringify({title: title, body: body, icon: iconUrl});
    document.getElementById( transfer-dom-area ).innerText = data;
    window.dispatchEvent(exportEvent);
  };
  return n;
}
window.webkitNotifications.createHTMLNotification = function (url) {
  var n = window.webkitNotifications.createHTMLNotification(url);
  n.show = function() {
    var data = JSON.stringify({ url  : url});
    document.getElementById( transfer-dom-area ).innerText = data;
    window.dispatchEvent(exportEvent);
  };
  return n;
};

然后,你们的活动聆听者可以向背景网页发送:

// Listen for that notification callback from your content script.
window.addEventListener( notificationCallback , function(e) {
  var transferObject = JSON.parse(transferDOM.innerText);
  chrome.extension.sendRequest({NotificationCallback: transferObject});
});

我补充说,在我的Gite Hub关于整个展期的学者(https://gist.github.com/771033)中, 在你的背景网页上,你可以说出你的国家扫盲计划。

我希望这能帮助你,我从这个意义上说出一个 ne子:





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签