is there possible calling gwt jsni method with chrome extension using chrome.tab.executeScript?

Neil Tseng

I have a gwt project that wrap in chrome extensions.

In GWT, I export a java method to jsni called:

Java Method: sendMessage(String msg);
export jsni: $wnd.sendMessage = function(msg) { ... };

then in chrome extension, I execute:

chrome.tabs.executeScript(tabId, {code: "sendMessage('hello');"}

but not thing happened, I've tried:

chrome.tabs.executeScript(tabId, {code: "alert('hello');"}

and it just works fine. but it just can't call my gwt jsni method.

Xan

Chrome content scripts exist in an isolated world.

$wnd.sendMessage is exported in the page context, and not accessible from a content script.

You'll need to inject code into the page itself (with a <script> tag) to access it.

See this canonical question on the topic, and this question can also be of use: Executing code at page-level from Background.js and returning the value

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Chrome Extension: executeScript on tab

From Dev

Chrome Extension - executeScript not in active tab

From Dev

Is it possible for a Chrome extension to close a current tab?

From Dev

Chrome extension - update certain tab using tabId

From Dev

chrome.tabs.executeScript into dataURI tab

From Dev

executeScript not populating global variable - Chrome Extension

From Dev

Chrome Extension: How to make background wait executescript?

From Dev

executeScript not populating global variable - Chrome Extension

From Dev

is possible to theme chrome with chrome extension?

From Dev

Unexpected results running chrome.tabs.executeScript() in my Chrome Extension?

From Dev

Is it possible to simulate incognito mode in current tab? (chrome extension)

From Dev

Is it possible to simulate incognito mode in current tab? (chrome extension)

From Dev

Get Chrome tab pid from Chrome extension

From Dev

Opening chrome extension in new tab

From Dev

Chrome extension: cannot create tab

From Dev

Unable to open a new tab using a button within a Chrome Extension popup

From Dev

chrome.tabs.executeScript with new browser tab not working?

From Dev

chrome.tabs.executeScript with new browser tab not working?

From Dev

Chrome extension open new tab on new tab

From Dev

Chrome Extension using DevTools

From Dev

Method to autoupdate Chrome Extension badge

From Dev

Chrome extension: create tab then inject content script into it

From Dev

Chrome extension to redirect tab to my page

From Dev

Trigger Chrome extension on new tab open

From Dev

Chrome extension get url of newly selected tab

From Dev

how to get active tab instantly in Chrome Extension

From Dev

google Chrome extension, add the tab to context menu

From Dev

Google chrome extension to open the New Tab page

From Dev

Injecting Javascript into Newly Created Tab in Chrome Extension

Related Related

  1. 1

    Chrome Extension: executeScript on tab

  2. 2

    Chrome Extension - executeScript not in active tab

  3. 3

    Is it possible for a Chrome extension to close a current tab?

  4. 4

    Chrome extension - update certain tab using tabId

  5. 5

    chrome.tabs.executeScript into dataURI tab

  6. 6

    executeScript not populating global variable - Chrome Extension

  7. 7

    Chrome Extension: How to make background wait executescript?

  8. 8

    executeScript not populating global variable - Chrome Extension

  9. 9

    is possible to theme chrome with chrome extension?

  10. 10

    Unexpected results running chrome.tabs.executeScript() in my Chrome Extension?

  11. 11

    Is it possible to simulate incognito mode in current tab? (chrome extension)

  12. 12

    Is it possible to simulate incognito mode in current tab? (chrome extension)

  13. 13

    Get Chrome tab pid from Chrome extension

  14. 14

    Opening chrome extension in new tab

  15. 15

    Chrome extension: cannot create tab

  16. 16

    Unable to open a new tab using a button within a Chrome Extension popup

  17. 17

    chrome.tabs.executeScript with new browser tab not working?

  18. 18

    chrome.tabs.executeScript with new browser tab not working?

  19. 19

    Chrome extension open new tab on new tab

  20. 20

    Chrome Extension using DevTools

  21. 21

    Method to autoupdate Chrome Extension badge

  22. 22

    Chrome extension: create tab then inject content script into it

  23. 23

    Chrome extension to redirect tab to my page

  24. 24

    Trigger Chrome extension on new tab open

  25. 25

    Chrome extension get url of newly selected tab

  26. 26

    how to get active tab instantly in Chrome Extension

  27. 27

    google Chrome extension, add the tab to context menu

  28. 28

    Google chrome extension to open the New Tab page

  29. 29

    Injecting Javascript into Newly Created Tab in Chrome Extension

HotTag

Archive