This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > August 2004 > .js files





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author .js files
PompeyFan

2004-08-05, 12:15 pm

When creating a rollover image, I would like to store the javascript in an
external [.js] file - is there anyway that the code can immediately be saved to
the file, or do you have to simply cut and paste the code into a created .js
file from the Code Window.

If there were 3 links each with a rollover state would it be necessary to save
the script to 3 different js files or can they all be placed into the same
file? When placing code within a .js file do I literally just paste it in? Is
there anything else that needs to be placed within the file?

I'd be most grateful for anyones assistance.



Justin Kozuch

2004-08-05, 7:14 pm

Hi There,

Well, you are in luck!!!

http://www.communitymx.com/abstract.cfm?cid=A3A8D

This free article, written by Jim Babbage, has everything you need to
know on how to externalize your JS files.

Enjoy!

--
Cheers,

Justin Kozuch
Founder, Dreaming in TO
Netkeepers.ca - Proud Hosting Sponsor of DreaminginTO.com Dreamweaver MX
2004 Certified Developer - http://www.macromedia.com/go/certification
Team Macromedia Volunteer for Dreamweaver MX 2004 -
http://www.macromedia.com/go/teammacromedia
CommunityMX Partner - http://www.communitymx.com

PompeyFan wrote:

> When creating a rollover image, I would like to store the javascript in an
> external [.js] file - is there anyway that the code can immediately be saved to
> the file, or do you have to simply cut and paste the code into a created .js
> file from the Code Window.
>
> If there were 3 links each with a rollover state would it be necessary to save
> the script to 3 different js files or can they all be placed into the same
> file? When placing code within a .js file do I literally just paste it in? Is
> there anything else that needs to be placed within the file?
>
> I'd be most grateful for anyones assistance.

Al Sparber- PVII

2004-08-05, 7:15 pm

PompeyFan wrote:
> When creating a rollover image, I would like to store the javascript
> in an external [.js] file - is there anyway that the code can
> immediately be saved to the file, or do you have to simply cut and
> paste the code into a created .js file from the Code Window.
>
> If there were 3 links each with a rollover state would it be
> necessary to save the script to 3 different js files or can they all
> be placed into the same file? When placing code within a .js file do
> I literally just paste it in? Is there anything else that needs to
> be placed within the file?
>
> I'd be most grateful for anyones assistance.


If you want an automated way of doing this, check out our Productivity
Tools:
http://www.projectseven.com/product...ls_01/index.htm

They are not free, but it includes a utility that not only allows you to
automatically create an external script file and move your scripts to
them, but it also allows you to move scripts back and forth from the
external file to your document and back again. This is handy when you
need to update scripts.

But here is the short answer if you'd like to do it yourself:
Create a new file with the JS extension: myscripts.js
Copy your JavaScript into this new file - do not include the <script>
tags:

<script type="text/javascript">
<!--
Copy only what is inside the tags and comments
//-->
</script>

Delete the scripts, the script tags, and the comments from your html
page and replace all of that with a link to the script file:

<script type="text/javascript" src="myscripts.js"></script>

--
Al Sparber - PVII
http://www.projectseven.com
DW Extensions - Menu Systems - Tutorials - CSS FastPacks
---------------------------------------------------------
Webdev Newsgroup: news://forums.projectseven.com/pviiwebdev/
CSS Newsgroup: news://forums.projectseven.com/css/
RSS/XML Feeds: http://www.projectseven.com/xml/




Justin Kozuch

2004-08-05, 7:15 pm

Just remembered something.

http://sandbox.dreaminginto.com/includes/index.php

I did a test suite for an issue I had at work, and this is what I came
up with.

A bit more involved than Jim's article, but works nonetheless.

--
Cheers,

Justin Kozuch
Founder, Dreaming in TO
Netkeepers.ca - Proud Hosting Sponsor of DreaminginTO.com Dreamweaver MX
2004 Certified Developer - http://www.macromedia.com/go/certification
Team Macromedia Volunteer for Dreamweaver MX 2004 -
http://www.macromedia.com/go/teammacromedia
CommunityMX Partner - http://www.communitymx.com

PompeyFan wrote:

> When creating a rollover image, I would like to store the javascript in an
> external [.js] file - is there anyway that the code can immediately be saved to
> the file, or do you have to simply cut and paste the code into a created .js
> file from the Code Window.
>
> If there were 3 links each with a rollover state would it be necessary to save
> the script to 3 different js files or can they all be placed into the same
> file? When placing code within a .js file do I literally just paste it in? Is
> there anything else that needs to be placed within the file?
>
> I'd be most grateful for anyones assistance.

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews