Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let's go one by one with your problems.</p> <blockquote> <p>1.When I click twice on the icon only, only then pop up appears.</p> </blockquote> <p>When you click on extension icon, your <code>browserAction.onClicked</code> handler gets executed and it just sets the popup. It does not open it. You have to click on extension icon again to open the popup. That is why you have to click twice.</p> <blockquote> <p>2.After I enter name and click login pop up gets closed which is fine.</p> </blockquote> <p>This is because you are redirecting to a new page which closes the extension popup.</p> <blockquote> <p>3.When I click again on icon, actually it should navigate to the website, but in my code it again shows pop up.</p> </blockquote> <p>Since you have setup popup for extension click, it has over-ridden the <code>chrome.browserAction.onClick</code> handler which is why you are not able to navigate to your website.</p> <blockquote> <p>4.When I reload the extension, it works correctly.</p> </blockquote> <p>This is because after reload, your <code>chrome.browserAction.onClick</code> is not over-ridden by popup and since login credentials are present in <code>localstorage</code>, your code does not over-ride it.</p> <h2>Solution1</h2> <ol> <li>In <code>background script</code>, check if the credentials are stored in <code>localstorage</code> then do not set the popup, else set the popup.</li> <li>Add the handler <code>chrome.browserAction.onClick</code> to always navigate to your website. You know that if popup opens then your handler will not be executed.</li> <li>When you store the credentials in localstorage and if they are correct, remove the popup.</li> <li>To remove popup, you can try <code>chrome.browserAction.setPopup({popup: ""});</code></li> </ol> <p>From <a href="http://developer.chrome.com/extensions/browserAction.html#events" rel="nofollow">chrome.broswerAction API</a></p> <blockquote> <p><strong>onClicked</strong> Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup.</p> </blockquote> <h2>Solution2</h2> <ol> <li>Popup has the same permissions which background scrips have. So instead of defining <code>chrome.browserAction.onClicked</code> event, just write your code in popup script.</li> <li>Check the localstorage, if credentials are present, create a new tab and open your page and close the popup with <code>window.close()</code></li> <li>Otherwise don't close the popup.</li> </ol> <p>PS: I have not tried it. Just giving you an idea.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload