Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8658557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:47:49+00:00 2026-06-12T15:47:49+00:00

Since injected script can’t do cross domain xmlhttp requests I tried, as it is

  • 0

Since injected script can’t do cross domain xmlhttp requests I tried, as it is advised in the manuals to send message from injected script to background script for it to do the job. But I cannot get the messages to work.

This is my code, it is only three files, as simple extension as it could be.

config.xml

<?xml version="1.0" encoding="utf-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" id="http://www.example.org/helloworld">
  <name>postMessage-testcase</name>
  <description>check if opera's postMessage fails</description>
</widget>

index.html

<!doctype html>
<html lang="en">
<head>
<script>
  opera.extension.onmessage = function(event) {
    alert("get the message!");
    opera.extension.postMessage("posting reply");
  };
</script>
</head>
<body></body>
</html>

includes/user.js

// ==UserScript==
// @include     *apod.nasa.gov*
// ==/UserScript==

opera.extension.onmessage = function(event) {
  alert("got reply !");
};

alert("yep, I'm on apod, proceeding with messages");
opera.extension.postMessage("message body");

The script should send back and forth messages when user opens apod.nasa.gov, but only one msg is send here, no messaging is taking place, also no error show up in the console.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:47:50+00:00Added an answer on June 12, 2026 at 3:47 pm

    The opera.extension.postMessage() method cannot be called from the background process because it doesn’t know which page/tab to post the message to. Instead, opera.extension.broadcastMessage() can be used to send a message to all tabs (see: http://dev.opera.com/articles/view/extensions-api-messaging-broadcastmessage/ )

    Alternatively, to send a message to the injected script in a particular tab:

    1. Listen for a connection event (opera.extension.onconnect) in the background process
    2. Run postMessage() from the event’s source object

    See: http://dev.opera.com/articles/view/opera-extensions-messaging/#backgroundscript_injectedscript

    By the way, don’t forget that what you use cross-domain XHR in the background process, you’ll need to allow access to the target domain in your config.xml file, for example:

    <access origin="http://apod.nasa.gov" subdomains="true"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since input and raw_input() stop the program from running anymore, I want to use
Since each thread has its own stack, its private data can be put on
i have tried to find the error since hours. i have no idea what
I've created a nice little modal message window for my app but I can't
since memcpy should be highly optimized nowadays, does it still make sense to optimize
Since regular jQuery animations are not fluent on iOS ( .hide() , slideDown() ),
since today im facing a strange problem. When i start my app in my
Since I am developing an iOS >= 5.0 application, I am trying to change
Since REST is stateless, each request that comes in has no knowledge of the
Since now I have only used plugin for editing and the way I use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.