Making a new window with JavaScript
a bonus example for those who have finished the HTML intro
This page assumes some basic programming knowledge...if you don't know
what a "variable" is, you may find this business opaque. So it goes....
This page has a simple example that shows how to spawn a new window from a
link. If you click this
link, you should see a window that is 400x400 containing the front page of
the new Russian Language Program site.
This whole business is created using JavaScript, a programming language used
to add interactivity and dynamic effects to basic HTML. NOTE: JavaScript has ABSOLUTELY NOTHING to do with Java...the
name was created by marketing folk at Netscape to cash in on the hype surrounding
the introduction of the object-oriented Java programming language a few years
back.
The main Javascript function (hidden in the document's head section) looks
like this:
function makewindow(someurl)
{
newwindow=window.open(someurl,"michaelwindow","scrollbars,width=400,height=400");
}
The variable someurl is the URL you want to open;
"michaelwindow" is simply a name for the window so you can refer to
it in another JavaScript function if necessary, and the final string parameter
("scrollbars,width=400,height=400") is a list of characteristics
that the window will have.
You invoke the window with an ordinary anchor tag, but instead of supplying a
URL for the HREF, you supply something like the following:
HREF="javascript:makewindow('http://www.humnet.ucla.edu/russian/');"
You may want to examine the source code for this page to see how it is all
put together.
|