This document describes the HTML and JavaScript magic necessary to create a hyperlink that then displays a panorama in a separate window of a given size.
First, create a JavaScript function that opens a window. Add the following to your HTML document, just before the <BODY> element:
<!--NOEDIT-->
<SCRIPT LANGUAGE="JavaScript">
function openWindow() {
window.open("","windowname","width=400,height=250,resizable=yes,toolbar=no,location=no,directories=no,status=yrd,menubar=no,scrollbars=no");
}
</SCRIPT>
<!--/NOEDIT-->
The <!--NOEDIT--> lines are not strictly necessary, but are HTML comments that might prevent your HTML editor from messing up the JavaScript code. The "windowname" parameter gives the window a name that you will use later, and can be anything you like. The other parameters ("width=..." etc.) are a mixture of semi-standard and Netscape-specific properties for new windows; it is safe to assume that the width and height parameters will be understood by any JavaScript-capable web browser, but the more esoteric parameters may be ignored by your web browser.
If a window named "windowname" is already opened, the function will do nothing.
Use the standard hyperlinking elements (<A HREF="panorama.wrl"> ... </A>) to create an ordinary hyperlink. Before doing anything fancy, test it to be sure that it works (and that it just replaces the HTML page with the panorama). Once it is working, add the following:
Add onclick="openWindow();" inside the <A> element; for
example:
<A HREF="http://.../" onclick="openWindow();">click
here</A>
This runs the openWindow() JavaScript
function that you wrote in step 1 when the user clicks on the hyperlink.
Also add TARGET="windowname" inside the <A> element,
for example:
<A HREF="..." onclick="..."
TARGET="windowname">click here</A>
This
tells the web browser to put the stuff in the HREF url into the window named
"windowname", which (if not already opened) will have just been
opened by the onclick/openWindow() function. Phew.
If you want the panorama to occupy only part of the new window, then you can simply create an HTML page that embeds the panorama, and refer to that HTML page in the <A HREF=".."> parameter. If you are using a Java applet to display panoramas, then you must use this technique, because it is not possible to hyperlink directly to a Java applet.
What if you have several panoramas and want to display each of them in a separate window that also contains some HTML code (instructions for navigating the panorama, perhaps, or a description of the panorama)? One way of doing that is to create a separate HTML document for each of the panoramas, and link to those different documents. However, if you have a lot of panoramas that can be very tedious and inconvenient.
A better way is to pass information about which panorama to display into the new window. This can be accomplished with some JavaScript and HTML, as follows:
For complete examples of all of these techniques, feel free to take a look at (and borrow) the source to our Demos page.