我正在尝试创建 chrome 扩展,它将从网页中读取特定标签内的文本......
但无法读取值
我需要在标签定义中选择文本,不包括 html 标签......
这里我想从标签“定义”
输出:是一种压倒性的想要拥有某些东西的冲动,通常与金钱有关,
假设网页是这样的
<div id="definition">
<div class="section blurb">
<p class="short"><i>Greed</i> is an overwhelming urge to have <i>more</i>
of something
<p class="long"><i>Greed</i> is often connected with money</p>
</div>
</div>
这就是我正在尝试的 popup.html
<script>
var newwin = chrome.extension.getBackgroundPage();
newwin.get();
</script>
背景.html
<Script>
function get()
{
var myDivObj = document.getElementById("definition");
if ( myDivObj ) {
alert (myDivObj.innerHTML);
}else{
alert ( "Alien Found" );
}
}
</Script>