FAQ 1: Should I paste the JavaScript Vision files into my HTML Web pages, use CFINCLUDE to place them in my CFM files, or use the SRC attribute of the SCRIPT tag?

FAQ 2: How can I use the JavaScript Vision Custom ColdFusion Tag custom tag to automatically detect whether the browser being used can use the SRC attribute of the SCRIPT tag?

FAQ 3: Is there any other way I can access the JavaScript Vision library, or any other JavaScript code, other than pasting it into each document or using the SRC attribute of the SCRIPT tag?

FAQ 4: How do I work around the limitations of the JavaScript getYear method?

FAQ 5: How do I center a browser window on the screen?

FAQ 6: Does it cost anything to use the JavaScript Vision library?

FAQ 7: May I alter your code for my own purposes?

Last Updated:


Question: Should I paste the JavaScript Vision files into my HTML Web pages, use CFINCLUDE to place them in my CFM files, or use the SRC attribute of the SCRIPT tag?

Answer: The SRC attribute of the SCRIPT tag is available in Internet Explorer 4+ and Netscape 3+ browsers. If you use the SRC attribute to load JavaScripts into your Web pages and your users are not using Internet Explorer 4+ and Netscape 3+ browsers, then they will get an error when the JavaScript is executed. Knowing which browsers your pages will be viewed in will help you decide the best means of using JavaScript files. (See the JavaScript Vision Custom ColdFusion Tag for a means to load JavaScript Vision files into ColdFusion Web pages.)

DHTML Diner See the webreference DHTML Diner article Loading External JS Files for DHTML Browsers.

Top of Page


Question: How can I use the JavaScript Vision Custom ColdFusion Tag custom tag to automatically detect whether the browser being used can use the SRC attribute of the SCRIPT tag?

Answer: By using the CGI.USER_AGENT variable to establish the browser and version, one can then establish whether to include or link to the JavaScript Vision files. (Two free tags, CF_Browser and CF_BrowserCheck, both translate the browser's USER_AGENT value into a set of variables that can be used in your ColdFusion Web pages. You can also develop your own or purchase a commercial version.) For example:

<CF_Browser>
<CFSET jsvUsage = "INCLUDE">
<CFIF ( BrowserType is "MSIE" and Version GTE "4" ) OR
        (BrowserType is "NS" and Version GTE "3")>
    <CFSET jsvUsage = "LINK">
</CFIF>
<CFSET jsvPath =
    IIf(  jsvUsage IS "INCLUDE",
          DE("../jsvInclude/"),
          DE("http://www.roaringforksoftware.com/JSV/")
          )>
<CFMODULE TEMPLATE="JS_VISION.cfm"
          MODULE="windowmgmt"
          USE="#jsvUsage#"
          MODULEPATH="#jsvPath#">

Top of Page


Question: Is there any other way I can access the JavaScript Vision library, or any other JavaScript code, other than pasting it into each document or using the SRC attribute of the SCRIPT tag?

Answer: Yes, but this option is not for the faint of heart. Use a hidden frame that contains a Web page with all the JavaScript that you want to reference (e.g., the JavaScript Vision library) pasted in it. To access a function from the hidden Web page on each visible Web page, you must provide a reference to that function (e.g., parent.frames[0].JSV_isEmpty()).

See:

Top of Page


Question: How do I work around the limitations of the JavaScript getYear method?

Answer: The best answer would be to use the getFullYear method but this method is available only in JavaScript 1.3. However, note what it says below for the different versions of JavaScript and JScript. One could use a browser sniffer and determine whether to call the the getFullYear method or the the getYear method, but this may not be reliable with browsers other than Netscape and Internet Explorer. That is why JSV_getFullYear function is recommended over the getFullYear or getYear method.

Browser JavaScript Version
Navigator 2 and IE3 1.0
Navigator 3 and Opera 1.1
Navigator 4.05 and lower and IE4 1.2
Navigator 4.06 and higher and IE5 1.3
Navigator 5 1.4

JavaScript 1.3. The getYear method returns the year minus 1900; thus:

JavaScript 1.2 and earlier versions. The getYear method returns either a 2-digit or 4-digit year: JScript. For the current century, the year is a 2-digit integer value returned as the difference between the stored year and 1900. For dates other than the current century, the 4-digit year is returned. For example, 1996 is returned as 96, but 1825 and 2025 are returned as-is.

Top of Page


Question: How do I center a browser window on the screen?

Answer: Carefully. This is due to the differences between Netscape Navigator and Internet Explorer in which size property of window they support.

Property Description Browser Support
outerWidth Specifies the horizontal dimension, in pixels, of the window's outside boundary. The outer boundary includes the scroll bars, the status bar, the tool bars, and other "chrome" (window border user interface elements). Netscape
outerHeight Specifies the vertical dimension, in pixels, of the window's outside boundary. The outer boundary includes the scroll bars, the status bar, the tool bars, and other "chrome" (window border user interface elements). Netscape
innerWidth Specifies the horizontal dimension, in pixels, of the window's content area. IE, Netscape
innerHeight Specifies the vertical dimension, in pixels, of the window's content area. IE, Netscape

For either Internet Explorer or Netscape, I recommend the following procedure to center a window using JavaScript Vision:

  1. Create a default set of x,y delta values (see JSV_xyValues) for each window opened. Why? Due to the differences in the call to each window. (Was the window opened with status? menubar? scrollbars? location?) This is currently only needed for Internet Explorer as the outerWidth and outerHeight window properties are not supported.

    For example
    var windowDeltas1 = new JSV_xyValues();
     
  2. Create a set of x,y values (see JSV_xyValues) for each window opened with the width and height attributes passed to window.open(). These will be the initial values to compute the deltas.

    For example
    var windowOuterDim1 = new JSV_xyValues(500,300);
     
  3. Calculate the actual deltas for the Internet Explorer window using the JSV_getWindowDeltas function.

    For example
    windowDeltas1 = JSV_getWindowDeltas(windowOuterDim1, myWindowHandle);
     
  4. Get the current dimensions of the browser window using JSV_getWindowDimensions. For Netscape, the window deltas will be zero and the JSV_getWindowDimensions function will return the outerWidth and outerHeight values. For Internet Explorer, the window deltas may not be zero and the JSV_getWindowDimensions function will return the innerWidth and innerHeight values with the window deltas added.

    For example
    var windDimensions1 = JSV_getWindowDimensions(windowHandle1, windowDeltas1);
     
  5. The last step is to get the position values for the left and top of the window using JSV_windowCenter, then pass these values to the moveTo method of window.

    For example
    var centerTopLeft = JSV_windowCenter(windDimensions1);
    windowHandle1.moveTo(centerTopLeft.x, centerTopLeft.y);

If you are dealing strictly with Netscape Navigator and a resizable window, then you need only pass the outerWidth and outerHeight values of the window to the JSV_windowCenter function. If you are dealing with Internet Explorer, then you need to follow the above steps.

If the browser window is not resizable, then you need only pass the values of the width and height attributes, when the browser window was open, to the JSV_windowCenter function.

Top of Page


Question: Does it cost anything to use the JavaScript Vision library?

Answer: All code provided on this site is free for use, provided that any copyright notices remain intact and that those web pages are freely accessible, i.e., not on pay sites. Use on an intranet is permitted. You may not sell or distribute the code without permission. All rights are retained by the author.

You are not required to display any links or buttons if you use code from this site. However, if you do wish to add a link please make it to the home page of this site (http://www.roaringforksoftware.com/).

Top of Page


Question: May I alter your code for my own purposes?

Answer: Yes you may, however any copyright is retained by the author as provided by law and any such notices must still be included in the code.

Top of Page