Skip to content

Instantly share code, notes, and snippets.

@andrijac
Created April 21, 2016 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrijac/cf57bac269a6d2592dea81b59b42e79c to your computer and use it in GitHub Desktop.
Save andrijac/cf57bac269a6d2592dea81b59b42e79c to your computer and use it in GitHub Desktop.
quick demo for controlling remote window
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Open</button>
<button onclick="gotoUrl()">goto</button>
<button onclick="focusWin()">focus</button>
<script>
(function(win){
var w;
function myFunction() {
w = win.open("http://www.yahoo.com");
}
function gotoUrl() {
w.location.href = "http://google.com";
}
function focusWin() {
w.focus();
}
win.myFunction = myFunction;
win.gotoUrl = gotoUrl;
win.focusWin = focusWin;
})(window);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment