onclick
事件无法在HTML文件中运行,外部javascript popup.js也无法在chrome扩展程序中使用。
这是popup.html
<!doctype html>
<html>
<head>
<title>getting started</title>
<script src="popup.js"></script>
</head>
<body>
<div onclick="myFunction()"></div>
</body>
</html>
这是popup.js
function myFunction() {
var d = new Date();
var weekday = new Array(7);
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
var n = weekday[d.getDay()];
var a = n;
switch (a) {
case "Sunday":
document.write('Breakfast - paaw bhaaji , lunch - peeli daal , dinner - chole chawal');
break;
case "Monday":
document.write('Breakfast - paaw bhaaji , lunch - kaali daal , dinner - chole chawal');
break;
case "Tuesday":
document.write('Breakfast - paaw bhaaji , lunch - hari daal , dinner - chole chawal');
break;
case "Wednesday":
document.write('Breakfast - paaw bhaaji , lunch - neeli daal , dinner - chole chawal');
break;
case "Thursday":
document.write('Breakfast - paaw bhaaji , lunch - gulabi daal , dinner - chole chawal');
break;
case "Friday":
document.write('Breakfast - paaw bhaaji , lunch - white daal , dinner - chole chawal');
break;
case "Saturday":
document.write('Breakfast - paaw bhaaji , lunch - red daal , dinner - chole chawal');
break;
default:
document.write('it can not be happen');
}
}
这是manifest.json
{
"manifest_version": 2,
"name": "Getting started example",
"description": "This extension shows a Google Image search result",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"activeTab"
]
}
请帮我解决这个问题。