How to create an extension in chrome to run a website
I am creating a chrome extension to run a web url in the popup . i am referencing these urls url 1 and Chrom extension example and created like this my mainfest.json file is
{
"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 file is
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 is
<!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>
it creates an icon on right side .It is opening the current page only in the popup when i click on the icon. But if i click on the links nothing happened. please help if any body knows about this
UPDATE
I also tried to include iframe like this
<iframe src="url"></iframe>
but it stops extension to work.
链接地址: http://www.djcxy.com/p/66584.html下一篇: 如何在chrome中创建扩展以运行网站