我在内容脚本的帮助下添加了一个弹出 Div。我添加了一个按钮来关闭该 DIV,为此我为我的函数popClose()调用了onClick事件,但它给出了未定义的函数。我该如何实现?
我的内容脚本代码如下:
var currentURL = document.location.href;
var body = document.getElementsByTagName("body")[0];
body.setAttribute("style", "background-color:red");
//get Top BlueBar Reference
var blueBar = document.getElementById("blueBar");
var blueBarHtml = blueBar.innerHTML;
//popUp Div for Options
var popUpDiv = "<div onclick='closepop();' class='popUpDiv'><div class=close>X</div></div>";
blueBar.innerHTML = popUpDiv+blueBarHtml;
//get page Nav ID
var tinyMan = chrome.extension.getURL("tinyman.png");
var pageNav = document.getElementById("pageNav");
var red = chrome.extension.getURL("red.png");
var yellow = chrome.extension.getURL("yellow.png");
var green = chrome.extension.getURL("green.png");
var blue = chrome.extension.getURL("blue.png");
var pageNavHtml = pageNav.innerHTML;
var liHTML = '<li id="Extra" class="navItem topNavLink middleLink">';
liHTML+='<a><img src="'+tinyMan+'" border="0" style="margin-bottom: 4px; display: inline-block;">';
liHTML+="<a>"
liHTML+='<div class="menuPulldown" style="display:block;"></div>'
liHTML+='</a>';
liHTML+='</li>';
//set new HTML
pageNav.innerHTML = liHTML+pageNavHtml;
function closepop()
{
alert("jj");
}