2012-04-04 10 views
1

Google Chromeで簡単なページアクション拡張を開発していますが、その目的は次のとおりです。アクセス方法Google Chromeの拡張子のポップアップから

  1. クリックすると、ユーザー名とパスワードの入力を求めるプロンプトが表示されます。
  2. 小さな検証の後、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> 

おかげで、 シャンカール

答えて

1

は、ポップアップウィンドウを作成します。ユーザー名とパスワードのフィールドを持つログイン用です。ポップアップフォームはその後、その後、記入し、フォームを送信する責任がある、あなたの(ページの)コンテンツスクリプトにメッセージを送信する背景ページにメッセージを送る提出され

http://code.google.com/chrome/extensions/browserAction.html#popups

http://code.google.com/chrome/extensions/content_scripts.html

これを行うには、メッセージパッシングを理解する必要があります:

http://code.google.com/chrome/extensions/messaging.html

+0

おかげで多くのリチャード。私は同じことを試み、私が何か困っているなら戻ってくる。 – Shankar

関連する問題