CFINCLUDE
to place them in my CFM files,
or use the SRC
attribute of the
SCRIPT
tag?
SRC
attribute of the SCRIPT
tag?
SRC
attribute of the SCRIPT
tag?
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.)
See the webreference DHTML Diner article Loading External JS Files for DHTML Browsers. |
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#">
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:
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 |
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:
outerWidth
and outerHeight
window properties
are not supported.
var windowDeltas1 = new JSV_xyValues();
width
and height
attributes
passed to window.open()
.
These will be the initial values to compute the deltas.
var windowOuterDim1 = new JSV_xyValues(500,300);
windowDeltas1 = JSV_getWindowDeltas(windowOuterDim1, myWindowHandle);
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.
var windDimensions1 = JSV_getWindowDimensions(windowHandle1, windowDeltas1);
moveTo
method of window
.
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.
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/).
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.
Copyright © 1999-2000 Roaring Fork Software. All rights reserved.