Google Chromeで簡単なページアクション拡張を開発していますが、その目的は次のとおりです。アクセス方法Google Chromeの拡張子のポップアップから
- クリックすると、ユーザー名とパスワードの入力を求めるプロンプトが表示されます。
- 小さな検証の後、gmail.comなどのウェブサイトのユーザー名とパスワードを入力する必要があります。
私は、ウィンドウロードでそれを行う方法の例をいくつか見て、別にポップアップを行うことができました。しかし、私はポップアップのhtmlから親htmlにアクセスすることができません。
ご協力いただければ幸いです。
ここに私のコードの内容があります。
manifest.jsonを:
{
"name": "My First Chrome App",
"version": "1.0",
"description": "Auto fill content",
"background": { "scripts": ["background.js"] },
"page_action" :
{
"default_icon" : "icon-19.png",
"default_title" : "Auto Fill",
"default_popup" : "test.html"
},
"permissions" : [
"tabs"
],
"icons" : {
"48" : "icon-48.png",
"128" : "icon-128.png"
},
"manifest_version": 2
}
background.js
function checkForValidUrl(tabId, changeInfo, tab) {
//checks whether the document contains Steve Jobs
if (tab.url.indexOf("gmail")) {
chrome.pageAction.show(tabId);
}
};
chrome.tabs.onUpdated.addListener(checkForValidUrl);
test.htmlという
<html>
<head>
<title> Hi Steve </title>
<script type="text/javascript">
function fill()
{
alert("inside method");
}
</script>
</head>
<body>
<form name="userinfo" id="userinfo">
username :
<input type="text" name="username"/>
password :
<input type="password" name="password"/>
<input type="button" value="Log In" onclick="fill()";/>
</form>
</body>
</html>
おかげで、 シャンカール
おかげで多くのリチャード。私は同じことを試み、私が何か困っているなら戻ってくる。 – Shankar