1

Is it possible to navigate to a new tab using js and then run the script on the new page?

ex:

window.open(url, '_blank');

setTimeout(function wait(){

//script to load on the new tab.

},5000);```
AzuraCF
  • 25
  • 2
  • Wouldn’t you be concerned if any arbitrary site could hypothetically spawn a pop up to `yourbank.com` and send your cookie data/session token to malicious actors…? – esqew Nov 09 '21 at 20:01
  • Please see this earlier answer, this is only possible if the domain is the same, otherwise, it will be rejected by CORS https://stackoverflow.com/questions/32357312/running-javascript-in-new-window-open – Snake_py Nov 09 '21 at 20:04
  • 1
    If you own `url` you can serve the JavaScript as part of the page. You can use [`postMessage()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) to send data between the parent and the child window/tab. For this to work you do need to setup the "message" event handler on the child page. – 3limin4t0r Nov 09 '21 at 20:14

0 Answers0