我创建了一个 chrome 扩展,其中有一个弹出窗口,其中包含以下 HTML 标记:
<html>
<head>
<style>
body {
font-family: 'Open Sans',arial,sans-serif;
background-color: #E5E5E5;
font-size: 13px;
text-shadow: 0px 1px rgba(255, 255, 255, 0.5);
}
</style>
</head>
<script type="text/javascript">function sendRequest(s,r){
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.sendRequest(tab.id, {search:s , replace:r}, function(response) {
console.log(response.farewell);
});
});
};
</script>
<body>
<label for="search">Search for</label><input name="search" id="search"></input>
<label for="replace">Replace with</label><input name="replace" id="replace"></input>
<button onclick="var s=document.getElementById('search').value;var r=document.getElementById('replace').value;sendRequest(s,r);">Go</button>
</body>
</html>
当我打开弹出窗口时,选择第一个输入字段,然后按 Tab 键,输入字段失去焦点,但第二个没有获得焦点。
如果我然后再次选择第一个并再次按 Tab,则第二个字段获得焦点。再次按下使按钮获得焦点,第三次按下使第一个字段再次获得焦点。
有谁知道为什么第一次按 Tab 键不起作用?