所以我对制作扩展有点陌生,所以我想从一个简单的开始。好吧,我认为这并不太难,但我无法让我的扩展程序以隐身模式和正常模式打开新标签页。
弹出页面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href='style.css' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
function Tabs() {
chrome.browserAction.onClicked.addListener(function() {
chrome.tabs.create({'url': "http://www.google.com"});
});
}
</script>
<base target="_blank">
</head>
<body>
<div id="Google">
<a href="google.nl"><input type="submit" onClick="Tabs" class="btn search-submit" value="Google"> </a>
</div>
<div id="Google">
<form action="websitelink" method="get" target="_blank">
<input type="submit" class="btn search-submit" value="website1">
</form>
</div>
<div id="Twitter">
<form action="websitelink" method="get"target="_blank">
<input type="submit" class="btn search-submit" value="website2">
</form>
</div>
<div id="Youtube">
<form action="websitelink" method="get"target="_blank">
<input type="submit" class="btn search-submit" value="website3">
</form>
</div>
</body>
</html>
我的 list 文件:
{
"name": "My Helper",
"version": "1.0",
"description": "My Helper",
"manifest_version": 2,
"browser_action": {
"default_icon": "icon128.png",
"default_title": "EXTENSTION DESCRIPTION",
"default_popup": "extension.html"
},
"permissions":
["tabs"]
}
我唯一想做的就是在新选项卡上打开网站。
最佳答案
也许这可以帮助你。
manifest.json
{ "name": "Name of extension",
"version": "0.1",
"manifest_version": 2,
"description": "Opens Tab!",
"browser_action": {
"default_icon": "icon128.png"
},
"icons": {
"48": "icon128.png"
},
"background":{
"scripts": ["background.js"]
}
}
背景.js
chrome.browserAction.onClicked.addListener(function(activeTab) {
var newURL = "http://www.google.nl";
chrome.tabs.create({ url: newURL });
});
背景.html
<html>
<head>
</head>
<body>
<h1>Hello people</h1>
<br />
<p>Hello fellow pele</p>
</body>
</html>
希望我的回答对你有帮助。
关于javascript - Google Chrome 扩展程序打开网址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23304370/