Welcome guest, is this your first visit? Create Account now to join.
Results 1 to 4 of 4

This is a discussion on problem with callback function in popup.html within the Plugins Development section, part of the Chrome Plugins category: the following javascript code is called within my popup.html: Code: function redirectAndInject(inputValue){ chrome.tabs.executeScript(null, {code:"window.location = 'http://google.com'"},function(tab) { chrome.tabs.executeScript(null, {code:"alert('inject Code ...


  1. #1
    dayscott is offline Junior Member
    Join Date
    Dec 2010
    Posts
    2

    Post problem with callback function in popup.html

    the following javascript code is called within my popup.html:

    Code:
    function redirectAndInject(inputValue){
      chrome.tabs.executeScript(null,
      {code:"window.location = 'http://google.com'"},function(tab) {
      chrome.tabs.executeScript(null,
      {code:"alert('inject Code in google.com');"}); });
    
    window.close();
    }
    unfortunately i get an error which says:

    Code:
    Uncaught TypeError: Cannot read property '0' of null
    (i know i am using "null" instead of "tab.id" as the first parameter of chrome.tabs.executeScript, but that should be ok)

  2. #2
    Waha's Avatar
    Waha is offline Senior Member
    Join Date
    Apr 2009
    Location
    Oregon
    Posts
    788

    Default

    It really doesn't look like there's anything wrong. Are you sure that's the only code that could give the error?
    Last edited by Waha; 01-09-2011 at 06:24 PM.
    ~ Projects ~
    Specialized: Carapass Auction Watcher, Kongregate Chat
    Libraries: bliplib
    Tools: manifest syntax highlighting & snippits
    ~ Happy to make extensions for pay too ;D ~
    Portfolio: Search and Share

  3. #3
    dayscott is offline Junior Member
    Join Date
    Dec 2010
    Posts
    2

    Default

    actually yes.

    i took the change page color example and simply modified it.

    to call the functions i use:
    Code:
    <div onclick="inject('www.ggoogle.com')" id="v">red</div>
    taken from http://code.google.com/chrome/extensions/samples.html

  4. #4
    Waha's Avatar
    Waha is offline Senior Member
    Join Date
    Apr 2009
    Location
    Oregon
    Posts
    788

    Default

    Quote Originally Posted by dayscott View Post
    actually yes.

    i took the change page color example and simply modified it.

    to call the functions i use:
    Code:
    <div onclick="inject('www.ggoogle.com')" id="v">red</div>
    taken from http://code.google.com/chrome/extensions/samples.html
    What's the definition of inject?
    ~ Projects ~
    Specialized: Carapass Auction Watcher, Kongregate Chat
    Libraries: bliplib
    Tools: manifest syntax highlighting & snippits
    ~ Happy to make extensions for pay too ;D ~
    Portfolio: Search and Share

Similar Threads

  1. How to know when popup.html loses focus ?
    By CoLoN3L in forum Chrome Plugins
    Replies: 3
    Last Post: 09-05-2010, 06:41 PM
  2. inconsistent function result
    By jaschulz in forum Bugs and Vulnerabilities
    Replies: 4
    Last Post: 05-23-2010, 04:53 AM
  3. Does chrome's download function is multithreading?
    By RedNada in forum Chrome Talk
    Replies: 0
    Last Post: 04-28-2010, 02:15 PM
  4. Chrome Extension function
    By Bhav in forum Plugins Development
    Replies: 1
    Last Post: 02-10-2010, 08:16 PM
  5. Problems with callback execution order
    By twinsen in forum Plugins Development
    Replies: 1
    Last Post: 08-15-2009, 05:54 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •