Re: New window - smaller size

by KeithWBell(at)aol.com

 Date:  Fri, 9 Jun 2000 05:34:47 EDT
 To:  vlabarca(at)uclink4.berkeley.edu,
hwg-techniques(at)hwg.org
  todo: View Thread, Original
In a message dated 09/06/00 02:03:12 GMT Daylight Time, 
vlabarca(at)uclink4.berkeley.edu writes:

> I am opening a new browser window (target = _blank) to display the new
>  page when a user clicks on a link. My question is: Is there any way to
>  make that new window smaller than the full size screen so it is obvious
>  to the browser that a new window was opened?

Veronica, you can use a little javascript to open the window at your chosen 
size, but still provide for users who don't have javascript enabled. First 
put a function like this in the HEAD of your file:

<script language="JavaScript" type="text/javascript">
<!--
function winOpen(url) {
  window.open(url, "_blank", "width=400,height=400,scrollbars,menubar");
}
-->
</script>

When called, this function will open a new window named "_blank" complete 
with menubar and scrollbars if required, sized at 400 x 400 pixels (change 
the numbers to suit the size you want). Then, at the appropriate place in 
your file, put the following:

blah blah text here
<script language="JavaScript" type="text/javascript">
<!-- 
document.write('<a href="javascript: winOpen(\'yourfile.html\')">Link 
Text<\/a>')
-->
</script>
<noscript>
<a href="yourfile.html" target="_blank">Link Text</a>
</noscript>
continue text blah blah

If users have javascript enabled, then the file "yourfile.html" will open up 
in the new window at the chosen size. The NOSCRIPT code ensures that those 
without javascript will still get a new window opening with "yourfile.html", 
but unfortunately you can't control the size of that one.

HTH
Keith Bell

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA