从chrome扩展中访问当前的html页面 [英] accessing the current html page from chrome extension
本文介绍了从chrome扩展中访问当前的html页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是铬合金扩展新手。
我想创建一个简单的Chrome扩展,用当前html页面的标题弹出警报。
当我执行时: alert(document.title)
,我没有得到它,因为文档对象不属于页面,而是属于扩展脚本(是否正确?)
如何获得正确的文档对象?
I'm new to chrome extensions.
I would like to create a simple chrome extension that popup an alert with the title of the current html page.
when I'm performing: alert(document.title)
, I'm not getting it because the document object doesn't belong to the page but to the extension script (is it correct?)
how do i get the right document object?
推荐答案
您可以使用标签页模块:
You can use the tabs module:
chrome.tabs.getCurrent(function(tab) {
alert(tab.title);
});
这篇关于从chrome扩展中访问当前的html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文