Scripts.js

F

Fred

I use a lot of JavaScript on some of my pages and I need to place it
(off-page) in its own file. The problem is that the script is in two parts
with the larger script within the body. The script within the <head> can
easily be placed in a file like <script src="myscripts.js"></script> but I'm
at a loss on how to deal with the script in the <body> part of the page. Any
ideas? Fred
 
S

Steve Easton

It's called the same way in the body as it is in the head section.

<script src="myotherscripts.js"></script>

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed..................
...............................with a computer
 
J

Jim Buyens

How about the Include Page component?

Or an SSI, such as:

<!-- #include file="lib/chklogin.inc" -->

Jim Buyens
Microsoft MVP
http://www.interlacken.com
Author of:
*-----------------------------­-----------------------
|\----------------------------­-----------------------
|| Microsoft Windows SharePoint Services Inside Out
|| Microsoft Office FrontPage 2003 Inside Out
||----------------------------­-----------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/----------------------------­-----------------------
*-----------------------------­-----------------------
 
T

Trevor L.

Fred,

I came across js emebdded with the body, and what I did was look at the js
and see what were functions and variable *definitions* and remove all of
them to an external.js.

In the body, I put
<script type ="text/javascript">

[ in here, I placed function calls and/or "document.write(..)"s that were
in the original code

</script>

I am not sure whether you get my drift or not
An example was wz_tolltips from http://www.walterzorn.com

I was able to place the entire code in an external.js (except for the last
line - see below)
In the body I just had:
<script type="text/javascript">
tt_Init()
</script>

tt_Init() was the last line of the original code

However, now I look at it, Steve's suggestion as just as good, if not
better.

Well, he is an MVP, so it would be better :)))
--
Cheers,
Trevor L.
Website: http://tandcl.homemail.com.au

Jim said:
How about the Include Page component?

Or an SSI, such as:

<!-- #include file="lib/chklogin.inc" -->

Jim Buyens
Microsoft MVP
http://www.interlacken.com
Author of:
*-----------------------------­-----------------------
*-----------------------------­-----------------------


I choose Polesoft Lockspam to fight spam, and you?
http://www.polesoft.com/refer.html
 
S

Steve Easton

Actually, tt_init() is not required to fire the script

Simply call the script file <script type ="text/javascript" src="scriptfile.js>
and any functions and routines contained within are loaded into a memory space
and able to be called from "events" contained within the html in the page, that fire functions
contained in the script.

;-)


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer

Trevor L. said:
Fred,

I came across js emebdded with the body, and what I did was look at the js
and see what were functions and variable *definitions* and remove all of
them to an external.js.

In the body, I put
<script type ="text/javascript">

[ in here, I placed function calls and/or "document.write(..)"s that were
in the original code

</script>

I am not sure whether you get my drift or not
An example was wz_tolltips from http://www.walterzorn.com

I was able to place the entire code in an external.js (except for the last
line - see below)
In the body I just had:
<script type="text/javascript">
tt_Init()
</script>

tt_Init() was the last line of the original code

However, now I look at it, Steve's suggestion as just as good, if not
better.

Well, he is an MVP, so it would be better :)))
--
Cheers,
Trevor L.
Website: http://tandcl.homemail.com.au

Jim said:
How about the Include Page component?

Or an SSI, such as:

<!-- #include file="lib/chklogin.inc" -->

Jim Buyens
Microsoft MVP
http://www.interlacken.com
Author of:
*-----------------------------­-----------------------
*-----------------------------­-----------------------


I choose Polesoft Lockspam to fight spam, and you?
http://www.polesoft.com/refer.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top