Google chrome extension 打开新页面的页面操作
我可以使用页面操作直接打开新页面吗?我的popup.html中有一个链接,但最好在他们单击图标时打开页面,这样他们只需要单击一次而不是两次Google chrome extension 打开新页面的页面操作,google-chrome-extension,Google Chrome Extension,我可以使用页面操作直接打开新页面吗?我的popup.html中有一个链接,但最好在他们单击图标时打开页面,这样他们只需要单击一次而不是两次 <!doctype html> <html> <head> <title>Popup</title> <link href="popup.css" rel="stylesheet" type="text/css"> </head> <body
<!doctype html>
<html>
<head>
<title>Popup</title>
<link href="popup.css" rel="stylesheet" type="text/css">
</head>
<body>
<a href="http://www.domain.com/details.html" target="_blank">click here</a>
</body>
</html>
弹出窗口
是的,实现这一点的方法如下:
chrome.pageAction.onClicked.addListener(函数(选项卡){
chrome.tabs.create({url:http://www.domain.com/details.html“,”活动“:true});
});
看
请注意,您需要在清单文件中声明选项卡权限:
"permissions": ["tabs",...],
我不认为有任何优雅的方式来处理页面上的两种情况操作点击:
chrome.pageAction.onClicked.addListener(function(tab) {
chrome.tabs.create({url: "http://www.example.com", "active":true});
});
PS:要删除弹出窗口,有两个选项:
实际上,您不需要
选项卡
权限<代码>选项卡是一个强大的权限,因此我建议您不要轻率地声明它!