[WEB4LIB] Re: Can JavaScript or ASP be used to adjust a

Thomas Bennett bennetttm at appstate.edu
Tue Jan 15 15:58:22 EST 2002


http://www1.appstate.edu/~bennettt/Grandfather/remote/ was my first attempt
a few years ago at making a popup menu.  When I wrote it the popup menu
showed all the information without resizing.  After testing on other
resolutions I found that the popup needed to be resizable so everyone would
be able to see all the information on the popup menu.  With that being the
case, we have never incorporated popups in our Web pages.   Well at least
not up until January 1, 2002, we asked our media services to propose a new
design for our home page and a similar template for lower pages.  The link
to the University home page opens a new window or browser depending on the
browser and setting you use.  My last edits to our old home page insured
there was no scripting and minimal graphics links and now the page is
nothing but graphics and java.  Obviously I don't have autonomous control
:-) .

Thomas


-----Original Message-----
From: web4lib at webjunction.org
[mailto:web4lib at webjunction.org]On Behalf Of Thomas Dowling
Sent: Tuesday, January 15, 2002 11:24 AM
To: Multiple recipients of list
Subject: [WEB4LIB] Re: Can JavaScript or ASP be used to adjust a



>At 10:28 AM 1/14/2002, Info Galway Library wrote:
>
>I am using JavaScript to open a small window to display a document. The
>document is not large? I want the window to be sufficiently large to
contain
>the document; no bigger or no smaller. Is there any means of opening a
>window of the required size? I am aware the document will be of a different
>size in different browsers.

If you realize that the document will display at different sizes, not just
in different versions of browsers, but in identical browsers with different
user settings, then you're way ahead of too many web designers.  However,
it also follows that you can't very reliably say "the document is not
large" (if you're talking about physical dimensions).  You just don't know.

>I am familiar with ASP and JavaScript.


You should be aware that none of the following can be *forced* on the
user.  In Opera 6 (and Mozilla, soon, we hope), there's a user setting to
disable pop-up windows, and that's without even disabling client-side
scripting.  Why?  Because many users really don't like them.  You're sure
this is a good idea, right?

If you're going to do this, it has to happen on the client side, so you'll
want to use JavaScript.  You're familiar with JavaScript, so you already
know that window.open uses pixel-based dimensions to size the new
window.  You could just stick with static pixel dimensions, but I'll tell
you from experience that there's no good window size that works on
everything from 640x480 to 1600x1200 resolutions.

You can (for many Javascript-enabled browsers) get the user's screen
resolution with screen.width and screen.height and make a reasonable guess
about what window size to use.  The following could be used to open a
window that covers about a quarter of the height and width of the
screen.  That will fit the same amount of content from screen to screen
more closely than static pixel sizes.

   //any errors are included as an exercise for the reader :-)
   if (screen.width) {
     ourWidth = Math.round(screen.width * .25);
   } else {
     ourWidth = 250;
   }
   if (screen.height) {
     ourHeight = Math.round(screen.height * .25);
   } else {
     ourHeight = 200;
   }
   ourSettings = "menubar=yes,scrollbars=yes,toolbar=yes,status=yes,";
   ourSetings = ourSettings + "directories=yes,location=yes,resizable=yes,"
   ourSettings = ourSettings + "width=" + ourWidth + ",";
   ourSettings = ourSetting + "height=", ourHeight;
   theNewWin = window.open("SomeURL", "SomeWindowName", ourSettings);
   theNewWin.focus();

A couple of general notes.  First, opening a new window for any purpose is
a pretty drastic measure.  We do it in our research databases, but only for
features that have the effect of taking users entirely out of the search
process.  Second, you have to be kind to your non-Javascript
browsers--there are more of us than you may know--so your hyperlink has to
work with and without JS.  With a little tweaking to the script above, this
will do the trick.

   <a href="read-this-right-now.html"
     target="VitallyImportantWindow"
     onclick="runTheScript('read-this-right-now.html',
'VitallyImportantWindow')">




More information about the Web4lib mailing list