如何在chrome中创建扩展以运行网站
我正在创建一个Chrome扩展,以在弹出窗口中运行Web网址。 我引用这些URL url 1和Chrom扩展示例,并像这样创建我的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>
它会在右侧创建一个图标。当我点击图标时,它仅在弹出窗口中打开当前页面。 但是,如果我点击链接没有发生任何事情。 如果有人知道这一点,请帮助
UPDATE
我也试图包括这样的iframe
<iframe src="url"></iframe>
但它停止扩展工作。
链接地址: http://www.djcxy.com/p/66583.html