Re: popup window
by KeithWBell(at)aol.com
|
Date: |
Wed, 26 Apr 2000 06:28:16 EDT |
To: |
hwg-techniques(at)hwg.org |
|
todo: View
Thread,
Original
|
|
In a message dated 26/04/00 08:21:25 GMT Daylight Time, Reywob(at)aol.com writes:
> Does anyone know of a script to launch a popup window, where the link will
> still work even if the visitor doesn't hava javascript enabled?
Here's one approach. First put a function like this between the HEAD tags in
your file:
<script language="JavaScript" type="text/javascript">
function winOpen(url) {
window.open(url, "newWin", "width=400,height=400,scrollbars,menubar");
}
</script>
This lets you control features of the popup window; in the example above the
window will have the name "newWin", it will be 400 pixels high and 400 wide,
scrollbars will be enabled, and it will have a menu bar.
Then for your link, do something like this:
here is a
<script language="JavaScript" type="text/javascript">
<!-- hide from non-javascript browsers
document.write('<a href="javascript: winOpen(\'newdocument.html\')">new
document<\/a> in a new browser window')
// stop hiding -->
</script>
<noscript>
<a href="newdocument.html" target="newWin">new document</a>
in a new browser window
</noscript>
replacing "newdocument.html" with the name of the file to be opened in the
popup. What you'll get is a line that (in any browser) reads:
here is a new document in a new window
with "new document" shown as a link. In javascript enabled browsers, it will
open in a popup with the charactersitics defined earlier. In non-javascript
browsers, it will open in a new window named "newWin", but you'll have no
control over the size or other window characteristics. If in this case you'd
rather have the new document open in the original window, then just leave out
the target="newWin" attribute.
HTH
Keith Bell
HWG hwg-techniques mailing list archives,
maintained by Webmasters @ IWA