473,670 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do i put my script in an extern file?

I have a script placed somewhere in the body of my HTML-doc.
I noticed that i'll be using the very same script in a large number
of document (all of them as the script regards the time of the
most recent edition of the given file).

I could place the script in every single document BUT:
1. I'm far too lazy to go through 100 documents doing one and the
same thing. That's for monkeys, not lazy humans.
2. Even if i wasn't so lazy, i'd have to reedit every single
document once i made a small change to the script. That's for
crazy monkeys!

So, how can i place the script in a file and how do i call the
file from my HTML-code?

--

Kindly
Konrad
---------------------------------------------------
May all spammers die an agonizing death; have no burial places;
their souls be chased by demons in Gehenna from one room to
another for all eternity and more.

Sleep - thing used by ineffective people
as a substitute for coffee

Ambition - a poor excuse for not having
enough sense to be lazy
---------------------------------------------------


Jul 23 '05 #1
11 1732
JW
It's easy. In the HTML-file you put :
<script language="JavaS cript" src="yourscript file.js"></script>

And you place your scriptfile in the "yourscriptfile .js"
JW
Jul 23 '05 #2
Just put

<script language="javas cript" src="nameofyour script.js"></script>

between the <head> tags...

The page will automatically read it as if it was in the
page itself...

Greetings
Jul 23 '05 #3
Thanks, Will try that tonight.

--

Kindly
Konrad
---------------------------------------------------
May all spammers die an agonizing death; have no burial places;
their souls be chased by demons in Gehenna from one room to
another for all eternity and more.

Sleep - thing used by ineffective people
as a substitute for coffee

Ambition - a poor excuse for not having
enough sense to be lazy
---------------------------------------------------


Jul 23 '05 #4
Konrad Den Ende wrote on 21 jun 2004 in comp.lang.javas cript:
Thanks, Will try that tonight.


This is no email, this is usenet posting.
So, for the benefit of all the other readers,
quote a significant [in the quality sense] part of the mail
you are referring to, [without resorting to topposting]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #5
"JW" <ja*******@hotp op.com> writes:
It's easy. In the HTML-file you put :
<script language="JavaS cript" src="yourscript file.js"></script>
The "type" attribute is required on script elements in HTML 4. The
"language" attribute is deprecated and can safely be omitted.
So, the recommended (and validating) way to write it would be:

<script type="text/javascript" src="yourscript file.js"></script>
And you place your scriptfile in the "yourscriptfile .js"


(and remember not to have <script> tags in the javascript file)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #6
> So, the recommended (and validating) way to write it would be:

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


I have placed following in the <head>
<script type="text/javascript" src="scripts.js "></script>
and made the script itself to a function returning a string as in
function getSome () { ... }
Then i call it by
<script>documen t.write (getSome ());</script>
but i get the message that the site is loaded but it contains errors.
I can't see the text i'm supposed to, either. What did i miss?

--

Kindly
Konrad
---------------------------------------------------
May all spammers die an agonizing death; have no burial places;
their souls be chased by demons in Gehenna from one room to
another for all eternity and more.

Sleep - thing used by ineffective people
as a substitute for coffee

Ambition - a poor excuse for not having
enough sense to be lazy
---------------------------------------------------


Jul 23 '05 #7
Konrad Den Ende wrote:
So, the recommended (and validating) way to write it would be:

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

I have placed following in the <head>
<script type="text/javascript" src="scripts.js "></script>
and made the script itself to a function returning a string as in
function getSome () { ... }
Then i call it by
<script>documen t.write (getSome ());</script>
but i get the message that the site is loaded but it contains errors.
I can't see the text i'm supposed to, either. What did i miss?

The scripting in the external .js file must be without opening and
closing HTML-tags
Also check if you can read the .js file directly from your server, maybe
you must update/change the index.cache files

If your browser says it contains errors, check out in which lines of
your page (in IE doubleclick on the yellow triangle)

I do it this way on a working site (eg. putting address info under each
page on http://www.autowiegel.nl)
In HEADER:
<script src="data1.js" language="javas cript"></script>

in BODY:
<SCRIPT language="Javas cript">
<!--
document.write( voettxt1)
//-->
</script>

The data1.js file contains the following (you'll notice a function
inside it too, but you can of course remove it);

<!--
function newwin2(page) {
empty =
open(page,"empt y","width=630,h eight=470,statu s=0,scrollbars= 1,resizable=0,l ocation=0,menub ar=1,top=100px, left=100px");
}
var voettxt1 = "<HR><CENTER><T ABLE align=middle bgColor=#ffffff
border=0><TBODY ><TR><TD><FON T face=arial,helv etica size=-1>Auto Wiegel
B.V.<BR>Kortewe g 1<BR>2641 GZ Pijnacker<BR><A
href=javascript :newwin2('route map.htm')><FONT
color=blue>Rout ekaart</FONT></A></FONT></TD><TD
width=25>&nbsp; </TD><TD><FONT face=arial,helv etica size=-1><TABLE
border=0><TBODY ><TR><TD><FON T face=arial,helv etica
size=-1>Tel.<BR>Fax.< BR>E-mail.<BR>Intern et.</FONT></TD><TD><FONT
face=arial,helv etica size=-1>+31 (0)15 369 22 52<BR>+31 (0)15 369 60
29<BR>in**@auto wiegel.nl<BR>ww w.autowiegel.nl </FONT></TD></TR></TBODY></TABLE></FONT></TD></TR></TBODY></TABLE></CENTER>";
//-->

See the result on, for instance, http://www.autowiegel.nl/pag02.htm

Richard

Jul 23 '05 #8
> Also check if you can read the .js file directly from your
server, maybe you must update/change the index.cache files


Hehe, it helps if one point to the right directory. Stupid mistake...
I put the file in an other directory (though one with the same
name but different path).

Nevertheless, i can't keep wondering about an ambigousity i see
here. What happens if i have two different functions stored in
two different files, yet call them the same name. Which one will
the computer thing i'm refering to?

--

Kindly
Konrad
---------------------------------------------------
May all spammers die an agonizing death; have no burial places;
their souls be chased by demons in Gehenna from one room to
another for all eternity and more.

Sleep - thing used by ineffective people
as a substitute for coffee

Ambition - a poor excuse for not having
enough sense to be lazy
---------------------------------------------------


Jul 23 '05 #9
Richard Hijdra wrote:
Konrad Den Ende wrote: <snip> The data1.js file contains the following (you'll notice a function
inside it too, but you can of course remove it);

<!--

^^^^

You have put this in an external JS file? Why? In javascript it is -
less than NOT pre-decrement - and a syntax error as there are not
operands for the operations.

Richard.
Jul 23 '05 #10

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

Similar topics

0
5081
by: Richard | last post by:
I am having trouble accessing a web page programmatically from .NET. Our proxy server is determined by a PAC script and all the standard .NET (and WinHttp) proxy techniques don't work for scripts. My current state is that I use the WinInet function 'InternetQueryOptionList' to get the proxy settings. This is working fine, I am able to detect that my IE settings use a PAC script. Next, I try using the WinHttp function...
4
2589
by: John Ratliff | last post by:
I have a few global variables in my app. They are defined in the main application class file and declared (extern) in a header which can be included by anyone who would want to use these variables. Two of the globals are pointers which are initialized at runtime. The others are classes whose values are initialized in the global space. When I had just the pointers, I didn't need to include the extern header in the defining class file. But...
18
4273
by: tweak | last post by:
What's the best way to use extern when using multiplefiles that is easiest to maintain? Is it best to declare: extern int a; in a header file and include the header file in all files except where it's defined.
12
2718
by: G Patel | last post by:
I've seen some code with extern modifiers in front of variables declared inside blocks. Are these purely definitions (no definition) or are they definitions with static duration but external linkage? Not much on this in the FAQ or tutorials.
19
3845
by: ccwork | last post by:
Hi all, I am reading "C: A Reference Manual" 4th ed and I get lost for the "extern". It says that global object without specifying the storage-class specifier will have "extern" as the default storage-class specifier. My (little) C experience tells me that an object with "extern" is to let the linker knows that the object is referencing the object defined in somewhere, and this "somewhere" object does not have the storage-class specifier...
5
16601
by: siliconwafer | last post by:
Hi all, I wanted to know that is use of extern keyword mandatory in case of global variables and functions used in other source files? i.e consider a following piece of code from MSDN explaining extern storage class: /****************************************************************** SOURCE FILE ONE *******************************************************************/ extern int i; /* Reference to i, defined below */
17
4921
by: Tapeesh | last post by:
I would like to know what is the expected behaviour of C compilers when an extern decleration is intialized. When the following code is compiled using gcc //File extern.c int arr ; int a ;
5
2852
by: Christian Christmann | last post by:
Hi, I've tree questions on the storage class specifier "extern": 1) Code example: int main( void ) { int b = -2; // my line 3 if ( a ) {
7
3527
by: blangela | last post by:
I am currently taking a course and one of the example programs showed a function prototype something like: extern void func(); I asked why the "extern" was necessary. Someone in the class (not the instructor) explained that if the same function prototype is used in more than one source file in a project, that the linker will complain.
0
8468
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8901
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8591
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6213
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5683
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4209
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4390
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2041
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1792
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.