hexid,
you might want to use JSON.parse instead of eval
http://code.google.com/chrome/extensions/xhr.html#security-considerations

On Sat, Jan 9, 2010 at 5:09 PM, hexid <[email protected]> wrote:
> Brian, I took your advice...and this is what i came up with...
>
> background.html:
>
> function showOrHide(tab)
> {
>  var req = new XMLHttpRequest();
>  req.open('GET', "manifest.json");
>  req.onreadystatechange = function()
>  {
>    if (req.readyState == 4)
>    {
>      var manifest = eval('(' + req.responseText + ')' );
>      if (localStorage["fbs_updateButton"] == "true")
>      {
>        if (manifest.version != localStorage["fbs_version"])
> {chrome.pageAction.show(tab.id);}
>        else{chrome.pageAction.hide(tab.id);}
>
>        chrome.pageAction.onClicked.addListener(function(tab)
> {chrome.tabs.create({url: 'options.html'})});
>      }
>    }
>  };
>  req.send("");
> }
>
> chrome.tabs.onCreated.addListener(showOrHide);
> chrome.tabs.onUpdated.addListener(function(tabid, changeinfo, tab) {
>  showOrHide(tab);
> });
>
>
> this executes the 'showOrHide' function when a new tab is created or
> refreshed and adds the page_action if the user has selected the option
> and the version in the manifest is different than the version stored
> in the localStorage...then if the user clicks on the page_action it
> will open a new tab with the options page, where i also put the
> changelog so that the user can see recent updates and edit their
> options to suit the latest update...
>
>
> On Jan 9, 4:46 pm, Brian Kennish <[email protected]> wrote:
>> On Sat, Jan 9, 2010 at 2:44 PM, hexid <[email protected]> wrote:
>> > hmm...I know how to do this on a page_action...not sure about a
>> > browser_action
>>
>> > in your 'popup.html' or whatever you named the page_action popup to
>> > be...add:
>>
>> > <script type="text/javascript">
>> > chrome.tabs.create({url: 'options.html'});
>> > window.close();
>> > </script>
>>
>> > and change the url to whatever you want it to open...i have my code so
>> > that in the options, the user can show/hide the page_action when i
>> > apply an update...
>> > the above code will open the options page in a new tab and close the
>> > popup when you click it...
>>
>> Hey Nick, the extra steps of opening and closing a popup aren't
>> necessary. Using a background page, you can add a listener for the
>> "onClicked" event on either the browser or page action.
>>
>> In Beeraj's case, a click on the browser action could trigger content
>> injection in the selected tab by sending a message to a content script
>> or running "chrome.tabs.executeScript()".
>>
>> In your case, a click on the page action could trigger the creation of
>> the new tab.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Chromium-extensions" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/chromium-extensions?hl=en.
>
>
>
>
-- 
You received this message because you are subscribed to the Google Groups 
"Chromium-extensions" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/chromium-extensions?hl=en.


Reply via email to