Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/styllloz/public_html/qa-include/qa-base.php on line 1175

Warning: session_start(): Cannot start session when headers already sent in /home/styllloz/public_html/qa-include/app/users.php on line 162

Warning: Cannot modify header information - headers already sent by (output started at /home/styllloz/public_html/qa-include/qa-base.php:1175) in /home/styllloz/public_html/qa-include/app/users.php on line 1267

Warning: Cannot modify header information - headers already sent by (output started at /home/styllloz/public_html/qa-include/qa-base.php:1175) in /home/styllloz/public_html/qa-include/app/page.php on line 356
Forwarding/processing of messages in the extensions Opera 11 - code-flow.club | Q&A

Forwarding/processing of messages in the extensions Opera 11


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
9 views
After reading the Extension for Opera: messaging decided to check.

Background script (index.html):
<!doctype html>window.addEventListener('load', function(){var button = opera.contexts.toolbar.createItem({ title: 'Send message', icon: 'icons/message.png' })button.addEventListener('click', function(event) {var tab = opera.extension.tabs.getFocused();if (tab)tab.postMessage({}); // можно попробовать и opera.extension.broadcastMessage({});}, false);opera.contexts.toolbar.addItem(button);}, false);


Valley script:
(function () { var storedLocation = "; if (opera.extension !== undefined) { opera.extension.onmessage = function(event){ opera.postError('got message:' + storedLocation); }; } window.opera.addEventListener("BeforeEvent.DOMContentLoaded", function (event) { storedLocation = window.location.href; opera.postError('loaded:' + storedLocation); }, false); })() 


The first thing I noticed processor BeforeEvent.DOMContentLoaded when opening new pages often fulfills more than once.

image

Clearly, there is a iframe with ads.

Okay, but if we click the button, then... the Message gets a background script is, but I would like another.

image

It is clear that the use to send the broadcastMessage() "delivers" the message to the background script of the main page, but to get it, and scripts from other tabs.

image

How to solve the problem of delivering messages to a script on active tab "basic" page?
by | 9 views

2 Answers

0 like 0 dislike
It's very confusing. Before you subscribe to an event BeforeEvent.DOMContentLoaded, check that the script is not in an iframe.
\r
if (window==window.top) { this is not an iframe }
by
0 like 0 dislike
Thanks, but it's not quite right.
\r
The problem is that when I send a message to the active tab, then it (the 99%) gets the background script of a frame of the main page as I would like.
\r
I first thought it was because the frame script is executed later and that it sets your callback. But using broadcastMessage() shows that fulfill both of the handler.
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
asked Mar 20, 2019 by ZoomLS
0 like 0 dislike
1 answer
asked Mar 28, 2019 by Serzhenko
110,608 questions
257,186 answers
0 comments
35,189 users