How to get reference to a new window of diff origin that is opened from current oneJavaScript open in a new window, not tabHow to get the value from the GET parameters?How do I get the current date in JavaScript?Get the size of the screen, current web page and browser windowOpen a URL in a new tab (and not a new window) using JavaScriptHow do you explicitly set a new property on `window` in TypeScript?How to open a Bootstrap modal window using jQuery?IE9, how to reference window from the popup window opened from the opener, after the opener refreshed himselfCordova InAppBrowser inception: Open a child window inside the original InAppBrowser window?How can I refer to “original” opener window from a chain of opened windows?
Who is "He that flies" in Lord of the Rings?
In The Incredibles 2, why does Screenslaver's name use a pun on something that doesn't exist in the 1950s pastiche?
Is it safe to remove Python 2.7.15rc1 from Ubuntu 18.04?
Open Drain pin not going to GND
Course development: can I pay someone to make slides for the course?
Is Dumbledore a human lie detector?
Does a single fopen introduce TOCTOU vulnerability?
Why are Payments from Apple to New Zealand and Australian bank accounts wire transfers?
Are the guests in Westworld forbidden to tell the hosts that they are robots?
What is the logic behind charging tax _in the form of money_ for owning property when the property does not produce money?
Does it make sense to use a wavelet that is equal to a sine of one period?
Using emission lines to determine redshift of a quasar
Oil draining out shortly after turbo hose detached/broke
Why do I seem to lose data using this bash pipe construction?
How does AFV select the winning videos?
How to show a "node near coord" even when it is out of bounds (with clip = true)?
Why are ambiguous grammars bad?
A life of PhD: is it feasible?
Is Jesus the last Prophet?
Noblesse oblige loanword in German
Parsing text written the millitext font
Have minipage take up entire page height
C++ logging library
Create a cube from identical 3D objects
How to get reference to a new window of diff origin that is opened from current one
JavaScript open in a new window, not tabHow to get the value from the GET parameters?How do I get the current date in JavaScript?Get the size of the screen, current web page and browser windowOpen a URL in a new tab (and not a new window) using JavaScriptHow do you explicitly set a new property on `window` in TypeScript?How to open a Bootstrap modal window using jQuery?IE9, how to reference window from the popup window opened from the opener, after the opener refreshed himselfCordova InAppBrowser inception: Open a child window inside the original InAppBrowser window?How can I refer to “original” opener window from a chain of opened windows?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
This is an Angular project. On my page A, I have a link that links to a page of a different origin, HTML as below:
...
<a href="https://another.origin"> PAGE B </a>
...
A user opened page B into a new window from page A. At this moment, A is still opened.
Now I want to post a message to B, like this referenceOfB.postmessage(msg, bOrigin) So I need to get a reference to B.
I tried window.open to get a reference to B but get null, not sure if this is the right way to approach it. Can anyone give some hints about how to do that?
javascript
add a comment |
This is an Angular project. On my page A, I have a link that links to a page of a different origin, HTML as below:
...
<a href="https://another.origin"> PAGE B </a>
...
A user opened page B into a new window from page A. At this moment, A is still opened.
Now I want to post a message to B, like this referenceOfB.postmessage(msg, bOrigin) So I need to get a reference to B.
I tried window.open to get a reference to B but get null, not sure if this is the right way to approach it. Can anyone give some hints about how to do that?
javascript
add a comment |
This is an Angular project. On my page A, I have a link that links to a page of a different origin, HTML as below:
...
<a href="https://another.origin"> PAGE B </a>
...
A user opened page B into a new window from page A. At this moment, A is still opened.
Now I want to post a message to B, like this referenceOfB.postmessage(msg, bOrigin) So I need to get a reference to B.
I tried window.open to get a reference to B but get null, not sure if this is the right way to approach it. Can anyone give some hints about how to do that?
javascript
This is an Angular project. On my page A, I have a link that links to a page of a different origin, HTML as below:
...
<a href="https://another.origin"> PAGE B </a>
...
A user opened page B into a new window from page A. At this moment, A is still opened.
Now I want to post a message to B, like this referenceOfB.postmessage(msg, bOrigin) So I need to get a reference to B.
I tried window.open to get a reference to B but get null, not sure if this is the right way to approach it. Can anyone give some hints about how to do that?
javascript
javascript
edited Mar 24 at 23:05
Robin
asked Mar 24 at 23:01
RobinRobin
5212918
5212918
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can use window.open to spawn a new window - this function returns a reference to the spawned window. You can then post a message to is using
postmessage.
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
var w = window.open('https://google.com')
w.postMessage('hello', "*"); // can use target domain instead of *
How about if I want to refer to the new window that is opened by a user but not by mywindow.openmethod?
– Robin
Mar 24 at 23:11
by a user on your site? You have to intercept his perceived link click and use window.open instead, I would think.
– jsdeveloper
Mar 24 at 23:15
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329414%2fhow-to-get-reference-to-a-new-window-of-diff-origin-that-is-opened-from-current%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use window.open to spawn a new window - this function returns a reference to the spawned window. You can then post a message to is using
postmessage.
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
var w = window.open('https://google.com')
w.postMessage('hello', "*"); // can use target domain instead of *
How about if I want to refer to the new window that is opened by a user but not by mywindow.openmethod?
– Robin
Mar 24 at 23:11
by a user on your site? You have to intercept his perceived link click and use window.open instead, I would think.
– jsdeveloper
Mar 24 at 23:15
add a comment |
You can use window.open to spawn a new window - this function returns a reference to the spawned window. You can then post a message to is using
postmessage.
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
var w = window.open('https://google.com')
w.postMessage('hello', "*"); // can use target domain instead of *
How about if I want to refer to the new window that is opened by a user but not by mywindow.openmethod?
– Robin
Mar 24 at 23:11
by a user on your site? You have to intercept his perceived link click and use window.open instead, I would think.
– jsdeveloper
Mar 24 at 23:15
add a comment |
You can use window.open to spawn a new window - this function returns a reference to the spawned window. You can then post a message to is using
postmessage.
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
var w = window.open('https://google.com')
w.postMessage('hello', "*"); // can use target domain instead of *
You can use window.open to spawn a new window - this function returns a reference to the spawned window. You can then post a message to is using
postmessage.
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
var w = window.open('https://google.com')
w.postMessage('hello', "*"); // can use target domain instead of *
edited Mar 24 at 23:14
answered Mar 24 at 23:04
jsdeveloperjsdeveloper
2,236158
2,236158
How about if I want to refer to the new window that is opened by a user but not by mywindow.openmethod?
– Robin
Mar 24 at 23:11
by a user on your site? You have to intercept his perceived link click and use window.open instead, I would think.
– jsdeveloper
Mar 24 at 23:15
add a comment |
How about if I want to refer to the new window that is opened by a user but not by mywindow.openmethod?
– Robin
Mar 24 at 23:11
by a user on your site? You have to intercept his perceived link click and use window.open instead, I would think.
– jsdeveloper
Mar 24 at 23:15
How about if I want to refer to the new window that is opened by a user but not by my
window.open method?– Robin
Mar 24 at 23:11
How about if I want to refer to the new window that is opened by a user but not by my
window.open method?– Robin
Mar 24 at 23:11
by a user on your site? You have to intercept his perceived link click and use window.open instead, I would think.
– jsdeveloper
Mar 24 at 23:15
by a user on your site? You have to intercept his perceived link click and use window.open instead, I would think.
– jsdeveloper
Mar 24 at 23:15
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329414%2fhow-to-get-reference-to-a-new-window-of-diff-origin-that-is-opened-from-current%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown