Env*_*nve 5 html javascript jquery google-chrome google-chrome-extension
我正在进行chrome扩展,我正在使用以下内容
的manifest.json
{
"name": "Test extension",
"version": "1.1",
"description": "Test extension.",
"icons": {
"128": "icon_128.png"
},
"chrome_url_overrides": {
"newtab": "cc.html"
},
"manifest_version": 2
}
Run Code Online (Sandbox Code Playgroud)
cc.html
<style>body,html{padding:0;margin:0}</style>
<iframe src="theiframe.html" frameborder="0" height="200px" width="200px">
</iframe>
Run Code Online (Sandbox Code Playgroud)
theiframe.html
<style>body,html{padding:0;margin:0}</style>
<form action="http://www.example.com/search">
<input autofocus="autofocus" tabindex="1" type="text" />
<input tabindex="2" value="search" type="submit"/>
</form>
Run Code Online (Sandbox Code Playgroud)
当用户打开新选项卡时,自动对焦将位于地址栏中.我希望用户能够改变它.是否有任何代码会自动对搜索输入进行自动对焦?
也许它不能仅使用一个iframe
.但是你可以做一个样本页面将重定向到一个新的标签页打开时,你想要的网页,所以input
已经autofocus
将被自动聚焦.
这是一种方法:
的manifest.json
"chrome_url_overrides": {
"newtab": "r.html"
},
Run Code Online (Sandbox Code Playgroud)
r.html
<html>
<head>
<title>Loading...</title> <!-- user friendly -->
<noscript>
<meta http-equiv="refresh" content="0; url=https://www.google.com"> <!-- in case javascript is disabled -->
</noscript>
<script src="s.js"></script>
</head>
<body></body>
</html>
Run Code Online (Sandbox Code Playgroud)
s.js
window.location="https://www.google.com";
Run Code Online (Sandbox Code Playgroud)
这是做到这一点的最佳方式(也许是唯一的方法).
归档时间: |
|
查看次数: |
1475 次 |
最近记录: |