'How Can i execute something in one window and it happens on another (chrome)
I want to make a GUI which opens in a pop-out window. It needs to be able to access the console from the original window.(aka needs to run commands from pop-out to the real window). maybe I could use jquery idk
var win = window.open("", "Poppout", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=350,height=400,top="+(screen.height-400)+",left="+(screen.width-840));
win.document.body.innerHTML = `<button onclick="javascript:alert("success!")" >test</button>`
you can do this but it doesn't do anything
Anything works. Im testing as we speak so yeah, thats it for my question sure hope this is possible
Solution 1:[1]
window.opener
it refers to the window object that .open() was ran on
docs
Solution 2:[2]
From your main page, you'll need native javascript window.parent :
<!DOCTYPE html>
<html>
<body>
<button onclick="parentLocation()">Open GUI</button>
<script>
function parentLocation() {
window.open("", "Poppout", "width=350, height=400");
alert(window.parent.location);
}
</script>
</body>
</html>
And if you run a script from the pop-up window, you'll need the javascript window.parent.opener property (or just parent.opener).
Source: w3schools.com
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Zastix |
Solution 2 | LBS |