JavaScript chrome.tabs.create/executeScript > call function that belongs to the page chrome.tabs.create,chrome.tabs.create example,chrome.tabs.create

I'm developing an extension for Google Chrome and the problem I'm having is I need to be able to call a JavaScript function that belongs to the webpage that's opened in the tab.

For details, the website is my website, therefore I know that function does exist. That function does a lot of things based on a string value. I want the user to be able to highlight text on any webpage, click a button from the Chrome extension that automatically loads my webpage and calls that function with the highlighted text as it's value.

Here's what I got so far:

chrome.tabs.create({ url: "https://mywebsite.com" }, function (tab) {
    var c = "initPlayer('" + request.text + "');"; ////'request.text' is the highlighted text which works
    chrome.tabs.executeScript(tab.id, { code: c });
});

But Chrome console says: "Uncaught ReferenceError: initPlayer is not defined."

I know that function does exist as it is in my code on my own website.

Any help is highly appreciated. Thanks!

Answer:1

There was an error in my code and there was also a js file included inside my page which prevented anything from executing inside $(document).ready(function () { ... i'm trying to sumbit this login ...

There was an error in my code and there was also a js file included inside my page which prevented anything from executing inside $(document).ready(function () { ... i'm trying to sumbit this login ...

  1. ajax post form data
  2. ajax post form example
  3. ajax post form data to controller
  4. ajax post form urlencoded
  5. ajax post form serialize
  6. ajax post form with file
  7. ajax post form php
  8. ajax post form javascript
  9. ajax post form laravel
  10. ajax post form as json
  11. ajax post form data to php
  12. ajax post form data javascript
  13. ajax post form data jquery
  14. ajax post form serialize json

I'm trying to make a button with two functions: function bigfont() {var font_is_small = true if (font_is_small = true) {document.getElementById('one').className= document.getElementById('one')....

I'm trying to make a button with two functions: function bigfont() {var font_is_small = true if (font_is_small = true) {document.getElementById('one').className= document.getElementById('one')....

  1. change boolean value java
  2. change boolean value python
  3. change boolean value javascript
  4. change boolean value on click angular
  5. change boolean value on click
  6. change boolean value c++
  7. change boolean value angular
  8. change boolean value in method java
  9. change boolean value sql
  10. change boolean value
  11. change boolean value arduino
  12. change boolean value js
  13. change boolean value typescript
  14. change boolean value vba
  15. change boolean value ruby
  16. change boolean value in database
  17. change boolean value angularjs
  18. change boolean value to string
  19. change boolean value in db
  20. change value boolean rails

I already have a php validation and form setup with PHP. So if someone forgets a username, the validation will add to the errors array and display it on the page when submitted. Now, instead of ...

I already have a php validation and form setup with PHP. So if someone forgets a username, the validation will add to the errors array and display it on the page when submitted. Now, instead of ...

  1. javascript function based classes
  2. javascript function based on id
  3. javascript function based
  4. javascript call function based on string
  5. javascript call function based on variable
  6. call javascript function based on condition

First I have a Controller like this: login.controller.js: angular.module('app').controller('LoginController', function($scope,UserService,$location) { $scope.submit = function() ...

First I have a Controller like this: login.controller.js: angular.module('app').controller('LoginController', function($scope,UserService,$location) { $scope.submit = function() ...

  1. angular jasmine tutorial
  2. angular jasmine mock service
  3. angular jasmine spyon
  4. angular jasmine run single test
  5. angular jasmine and karma
  6. angular jasmine createspyobj
  7. angular jasmine stub
  8. angular jasmine vs jest
  9. angular jasmine mock input
  10. angular jasmine mock observable
  11. angular jasmine unit test
  12. angular jasmine inject
  13. angular jasmine vs karma
  14. angular jasmine click button
  15. angular jasmine test event emit
  16. angular jasmine inject service
  17. angular jasmine async
  18. angular jasmine @input
  19. angular jasmine test window.location.href
  20. angular jasmine sleep