JavaScript Example 2-1
Floating (Remote) Windows

Click Here for Previous JavaScript Tutorial Home Click Here for Next

The first part of the example code is from Dr. Clue's Javascript tutorial,

The second part is based on some code from Netscape.

Sample Code

A floating window should pop up as soon as this page loads:

  <body onload="LaunchRemote()">

which calls the following JavaScript function:

    var Wremote = null;
    function LaunchRemote()
         szoptions = 'width=500,height=200,resizable=0';
         Wremote ='', 'YourRemote', szoptions);
         if(Wremote != null)
            if(Wremote.opener == null) 
                Wremote.opener = self;
            Wremote.location.href = 'example6-remote.htm';

Writing to a remote Window

Here is some sample code from the section of Netscape's JavaScript reference manual.

Click here to launch a new remote window and write to it.

The link above uses an href to invoke a JavaScript function as follows:

<a href="javascript:launchRemote2()">here</a>

The launchRemote2 function is as follows:

var msgWindow = null;
function launchRemote2() {"","displayWindow","menubar=yes")
      ("<HEAD><TITLE>Message window</TITLE></HEAD>")
      ("<CENTER><BIG><B>Hello, world!</B></BIG></CENTER>")

I wanted to see if we can write more to the window after it is open. So click here to try it. The link calls the following function:

function write2() {
      ("<BR><BR><CENTER><BIG><B>Here's Some More Text!</B></BIG></CENTER>")

Let's try to write a link... Click here. The link calls the following function, "write3()":

function write3() {
	 '<BR><BR><CENTER><BIG><B><a href="javascript:window.close()">CLOSE WINDOW</A></B></BIG></CENTER>')
As you can see, it works great!
Click Here for Previous JavaScript Tutorial Home Click Here for Next