我正在创建一个Chrome扩展程序,以便在弹出窗口中运行网址。我引用了这些网址url 1和Chrom extension example并创建了这样的网址 我的 mainfest.json 文件是
{
"manifest_version": 2,
"name": "Protecto",
"description": "This extension will connect you with protecto application",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"activeTab",
"https://www.url.com"
]
}
popup.js 文件
var xmlhttp = new XMLHttpRequest();
var url = "https://www.url.com/User/Login";
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("status").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
popup.html 是
<!doctype html>
<!--
This page is shown when the extension button is clicked, because the
"browser_action" field in manifest.json contains the "default_popup" key with
value "popup.html".
-->
<html>
<head>
<title>Getting Started Extension's Popup</title>
<style>
body {
font-family: "Segoe UI", "Lucida Grande", Tahoma, sans-serif;
font-size: 100%;
}
#status {
/* avoid an excessively wide status text */
white-space: pre;
text-overflow: ellipsis;
overflow: scroll;
width: 900px;
height: 600px;
}
</style>
<!--
- JavaScript and HTML must be in separate files: see our Content Security
- Policy documentation[1] for details and explanation.
-
- [1]: https://developer.chrome.com/extensions/contentSecurityPolicy
-->
<script src="popup.js"></script>
</head>
<body>
<div id="status"> </div>
<img id="image-result" hidden>
</body>
</html>
它在右侧创建一个图标。当我点击图标时,它只在弹出窗口打开当前页面。但如果我点击链接没有发生任何事情。如果有任何人知道这个,请帮忙
更新
我还试图像这样包含iframe
<iframe src="url"></iframe>
但它会停止扩展工作。