PDA

View Full Version : How can pop ups control the main window


shashgo
08-27-2002, 10:05 PM
I am trying to control the original window through a pop up window, but I just cant seem to get it to work. I need help with doing this.

<!--The code for the main window-->
<html>
<head>
<script language="javascript">
window.open(''","popup","width=400,height=400");
popup.document.write("Click the button to load a new URL in the main window"+<br>);
popup.document.write("<input type='button' value='Load new URL in the main window' onClick='javascript:top.location.href=http://www.yahoo.com');
</script>

<body>
Click<a href="javascript:OpenWin()">here</a> to open new window
</body>
</html>

This is what Im trying to do:
- click a link in the main window to open a popup window
- Have the main window add a link in the popup window
- when the user click the link in the popup window, the yahoo web page is loaded in the main window

Please help!!

adios
08-27-2002, 10:25 PM
Where would you like to start?

1) Unnamed function (OpenWin)
2) Syntax error - window.open(''","popup
3) Using window name as a 'handle' on window object (it isn't)
4) Syntax error - window"+<br> );
5) Unnecessary: onClick='javascript:
6 ) No document.close() following .write()
7) Fragmentary HTML page (will work but isn't well-formed)

I'd suggest a good JS book!

<html>
<head>
<script language="javascript">

var popup = null;
function OpenWin() {
popup = window.open('','popup','width=400,height=400');
popup.document.write('Click the button to load a new URL in the main window<br><form>');
popup.document.write('<input type="button" value="Load new URL in the main window" ');
popup.document.write('onClick="opener.location=\\'http://www.yahoo.com\\'"></form>');
popup.document.close();
}

</script>
</head>
<body>
Click <a href="javascript:void OpenWin()">here</a> to open new window
</body>
</html>

Mr J
08-27-2002, 11:03 PM
adios!

:eek:


It is nice to know that there is somewhere you can go to get help when you have a problem without fear of remonstration.

It does not help to belittling them in the process.

Remember you was a newbie once too.