Window Changing Opener URL

[Total: 0    Average: 0/5]

This opens up a new window and that windows contents are created by the html/javascript within the first window. The second window has a href that allows the user to change the URL loaded in the first window.

Body Code:

<script type=text/javascript> 
function newWin(urlLoc) {
  var _temp = "";
  _winName = "MyNewWindow";
  _info = "toolbar=no"; // yes|no 
  _info += ",location=no"; // yes|no 
  _info += ",directories=no"; // yes|no 
  _info += ",status=yes"; // yes|no 
  _info += ",menubar=no"; // yes|no 
  _info += ",scrollbars=auto";// auto|yes|no 
  _info += ",resizable=yes"; // yes|no 
  _info += ",dependent"; // close the parent, close the popup, omit if you want otherwise 
  _info += ",height=300";
  _info += ",width=420";
  _info += ",left=100";
  _info += ",top=100";
  DispWin=window.open(urlLoc,_winName,_info);
  _temp += "<html><head></head><body>NEW WINDOW<BR>";
  _temp += "<a href='javascript:opener.document.location="http://www.js-examples.com/"'>Click To Change Other Window URL</a>";
  _temp += "</body></html>";
  DispWin.document.open();
  DispWin.document.write(_temp);

  DispWin.document.close();
} 

</script>

<a href="javascript:newWin('')">Open New Window</a><BR>

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *