Tarek El-Mallah 重新加载弹出窗口的方法确实有效,但它对您不起作用,因为您使用 manifest_version : 2 并且不允许使用内联脚本...
http://code.google.com/chrome/extensions/manifestVersion。 html
另外,这是一个已知问题....
http://code.google.com/p/chromium/issues/detail?id=111660
以下是适用于 manifest_version 的版本:2.....
清单.json
{
"name": "Browser Action PopUp focus/tab test",
"version": "1.0",
"description": "A test to show that on opening a popup you cant set focus and the tab index is not honored on the first select. See, http://stackoverflow.com/questions/9070727/tab-key-not-working-in-popup-in-chrome-extension.",
"browser_action": {
"default_title": "Browser Action PopUp focus/tab test.",
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"manifest_version" :2
}
popup.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="popup.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sample Extens</title>
</head>
<body style="padding: 0px; margin: 0px;" >
<div id="Def">
<input type="text" id="textbox" name="aName" value="" placeholder="blah" />
</div>
</body>
</html>
popup.js
if (location.search !== "?foo") {
location.search = "?foo";
throw new Error; // load everything on the next page;
// stop execution on this page
}
function onLoad() {
document.getElementById("textbox").focus();
}
window.onload = onLoad;