[thelist] Pass variable to js include file?
.jeff
jeff at members.evolt.org
Thu Sep 26 03:03:01 CDT 2002
ryan,
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Joshua Olson
>
> Another option is to have your favorite script engine,
> such as CF, PHP, etc, actually parse js files. Then
> you can simply do this:
>
> <script language="JavaScript" src="includeme.js?myvar=1"
> type="text/javascript"></script>
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
another option would be to use the file extension for your choice of server-side scripting and then simply return the write mime-type when serving that particular page. just because it's an external javascript file doesn't mean it has to have a .js file extension.
<script language="JavaScript"
type="text/javascript"
src="/scripts/menu.cfm?myvar=1"
></script>
in menu.cfm (using cf cause that's what i know), place the following tag at the top of the file:
<cfcontent type="text/javascript">
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> The second platform is only an option if you have the
> means to change the way the web server operates. In
> IIS it means adding the js extension to the list of
> extension parsed by an installed parser.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
the advantage to not adding the .js file extension to the files that are parsed are that you don't incur the additional overhead of unnecessarily parsing a bunch of .js files just so you can do dynamic server-side stuff in one of them. you also don't need access to the webserver settings at all.
.jeff
http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/
More information about the thelist
mailing list