473,394 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Storing Scripts on a separate page

Hi, How can I store all my scripts on a separate page and then call
them from the html page that I want to use them on? the <head> section
is getting too cluttered and I would like to store all in one place.
Anyone know how? Cheers
Jul 20 '05 #1
8 1519

"DeadCert" <re******@hotmail.com> wrote in message
news:b5**************************@posting.google.c om...
Hi, How can I store all my scripts on a separate page and then call
them from the html page that I want to use them on? the <head> section
is getting too cluttered and I would like to store all in one place.
Anyone know how? Cheers


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

Where some.js contains JS code only.
JW

Jul 20 '05 #2
Janwillem Borleffs wrote:
Hi, How can I store all my scripts on a separate page and then call
them from the html page that I want to use them on? the <head> section
is getting too cluttered and I would like to store all in one place.


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

Where some.js contains JS code only.


If the OP has several files of javascript already, that doesn't compress
to one statement, right? I tried this once--I found nothing to include
javascript from another javascript file, I seem to need a SCRIPT tag for
every file. Correct me if I'm wrong. I love to be wrong on such issues ;-)

--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Jul 20 '05 #3

"Bas Cost Budde" <ba*@heuveltop.org> wrote in message
news:bv**********@news2.solcon.nl...
If the OP has several files of javascript already, that doesn't compress
to one statement, right? I tried this once--I found nothing to include
javascript from another javascript file, I seem to need a SCRIPT tag for
every file. Correct me if I'm wrong. I love to be wrong on such issues ;-)


You can include one js file, which includes the required files by document
writing the appropriate script tags.

Anyways, the OP would benefit from a thorough re-organisation of his
files...
JW


Jul 20 '05 #4
Bas Cost Budde wrote:
Janwillem Borleffs wrote:
Hi, How can I store all my scripts on a separate page and then call
them from the html page that I want to use them on? the <head> section
is getting too cluttered and I would like to store all in one place.

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

Where some.js contains JS code only.

If the OP has several files of javascript already, that doesn't compress
to one statement, right? I tried this once--I found nothing to include
javascript from another javascript file, I seem to need a SCRIPT tag for
every file. Correct me if I'm wrong. I love to be wrong on such issues ;-)


You are correct, but there is one solution that comes to mind (I am sure
there are others)...

myHtml.html:
<script type="text/javascript" src="some.js"></script>

some.js:
function writeScript( JSfile )
{
document.write("<script type='text/javascript' src='" +
JSfile + "'></scr" + "ipt>");
}

writeScript("file1.js");
writeScript("file2.js");
writeScript("file3.js");
....

Jul 20 '05 #5
DeadCert wrote:
Hi, How can I store all my scripts on a separate page and then call
them from the html page that I want to use them on? the <head> section
is getting too cluttered and I would like to store all in one place.
Anyone know how? Cheers

I'm doing exactly the same using frames.
One of them is reserved for js only.

It has an additional (could be significant) benefit and that is that you
can also 'store' interpage states here. So loading a page with knowledge
about its previous state/ predecessor becomes possible as well.
Try and do this with a js variable in the page and then reloading it!

The js frame thus becomes like a library of sorts that is always accessible
from anywhere within the browser.

I'm sure there are people that won't like this but it works for me & very
well so I might add.
My 2c

Cheers,
Fermin DCG
Jul 20 '05 #6
Brian Genisio wrote:
Bas Cost Budde wrote:
If the OP has several files of javascript already, that doesn't
compress to one statement, right? I tried this once--I found nothing
to include javascript from another javascript file, I seem to need a
SCRIPT tag for every file. Correct me if I'm wrong. I love to be wrong
on such issues ;-)


You are correct, but there is one solution that comes to mind (I am sure
there are others)...

myHtml.html:
<script type="text/javascript" src="some.js"></script>

some.js:
function writeScript( JSfile )
{
document.write("<script type='text/javascript' src='" +
JSfile + "'></scr" + "ipt>");
}

writeScript("file1.js");
writeScript("file2.js");
writeScript("file3.js");
...

Now isn't it so that document.write replaces the existing content? That
is rather harsh for what I have in mind.

--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Jul 20 '05 #7

Now isn't it so that document.write replaces the existing content? That
is rather harsh for what I have in mind.


That is incorrect... in this context. document.write works differently
in two distinctively different contexts:

1. While the page is still parsing... Everything written is appended
after the current script tag, and then parsed into the document

2. After the page has parsed, ie: an action has occured (such as onLoad,
onClick, etc)... In this case, it overwrites everything.

The context I gave, is of type 1. If you do it in inline scripting, you
have nothing to fear.

To clarify:

<SCRIPT ...> document.writeln(...) </SCRIPT>

will append after the script tag

<SCRIPT ...> function ABC(...) { document.writeln(...); } </SCRIPT>
<a href=... onClick="ABC(...)">...</a>

will wipe out the page with the new text, when the link is clicked

Brian

Jul 20 '05 #8
Thank you.
--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Jul 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: J P Singh | last post by:
Hi Guys I am trying to store the currency symbol used for a trasaction in a database field but rather than store £ it stores £ (see the wierd character at the beginning of the symbol) instead....
4
by: JCO | last post by:
Can somebody help me move scripts into a separate file (ie JavaScript) so that I can simply call the script from the body... and have it execute. I've done simple (couple to several lines) ones...
2
by: Mark Hannon | last post by:
I am trying to wrap my brain around storing form elements inside variables & arrays before I move on to a more complicated project. I created this simple example to experiment and as far as I can...
7
by: ergobob | last post by:
Hello, I have two small PHP scripts running on a test page at: http://www.usernomics.com/ergonomic-products-accessories5.html Both scripts work perfectly when there is one script on a page....
6
by: bissatch | last post by:
Hi, I am currently writing a news admin system. I would like to add the ability to add images to each article. What I have always done in the past is uploaded (using a form) the image to a...
2
by: newjazzharmony | last post by:
All, I'd appreciate it if someone could answer these questions for me. This scenario applies to an ASP dot net application that is deployed in a web farm. 1) Does the application live in a...
6
by: (PeteCresswell) | last post by:
User wants to go this route instead of storing pointers in the DB and the documents outside. Only time I tried it was with only MS Word docs - and that was a loooong time ago - and it seemed to...
5
by: shapper | last post by:
Hello, I am working on a web site where I have a master page. Most web site pages use this master page as base. Some scripts are used in all pages ... other just in a few pages. Should I load...
3
by: Eric Wertman | last post by:
I've a number of scripts set up that require a username/password combination to log in elsewhere. It's gotten to the point where I need to keep them in a more secure location, instead of just in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.