473,388 Members | 1,606 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,388 software developers and data experts.

Include in many pages

Hi there,

I have a bit of java script which I would like to include in all of my html
pages.

Is there an easy way to include it with a reference or something.

I don't want to have to copy and paste the code to the top of each page as
if I then change the code I have to go through all pages to change it.

Any help would be appreciated.

I don't know a great deal about javascript or html but know a fair bit about
other programming languages.

Thanks in advance

--

Jamie Allison
Sheffield Hallam University
Software Engineering
Final Year
Jul 23 '05 #1
6 1238
"Jamie" <ja**********@hotmail.com> wrote in message
news:fw**************@newsfe5-win.ntli.net...
Hi there,

I have a bit of java script which I would like to include in all of my html pages.

Is there an easy way to include it with a reference or something.

I don't want to have to copy and paste the code to the top of each page as
if I then change the code I have to go through all pages to change it.

Any help would be appreciated.

I don't know a great deal about javascript or html but know a fair bit about other programming languages.

Thanks in advance

--

Jamie Allison
Sheffield Hallam University
Software Engineering
Final Year


Place the JavaScript code in a file (e.g. "yourfile.js") then use:

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

in the <head> section of your Web page.
Jul 23 '05 #2
I Have done this now but still not working.

I have created a file called javacode.js and put my javascript in there.
The file starts

<script language="JavaScript">
<!--
Javascript functions here
//-->
</script>

I have then got my html page below which starts as shown. Is that the right
place to put the script type?

<html>
<head>
<title>Page Title</title>

<meta>
<link rel="stylesheet" type="text/css" href="main.css">

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

</head>
<body>

My javascript works fine if I put it directly onto the page in place of the
one include line.

Thanks for your help so far.

Regards

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:Mp********************@comcast.com...
"Jamie" <ja**********@hotmail.com> wrote in message
news:fw**************@newsfe5-win.ntli.net...
Hi there,

I have a bit of java script which I would like to include in all of my

html
pages.

Is there an easy way to include it with a reference or something.

I don't want to have to copy and paste the code to the top of each page
as
if I then change the code I have to go through all pages to change it.

Any help would be appreciated.

I don't know a great deal about javascript or html but know a fair bit

about
other programming languages.

Thanks in advance

--

Jamie Allison
Sheffield Hallam University
Software Engineering
Final Year


Place the JavaScript code in a file (e.g. "yourfile.js") then use:

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

in the <head> section of your Web page.

Jul 23 '05 #3
Just had a thought.

My java code has 3 function which I call on the HTML page. Is there any
particular way I have to call the function now it is included this way
instead of the code directly there?

Such as javascrips.ja/MM_swapImgRestore()

previously just called by MM_swapImgRestore()

Regards

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:Mp********************@comcast.com...
"Jamie" <ja**********@hotmail.com> wrote in message
news:fw**************@newsfe5-win.ntli.net...
Hi there,

I have a bit of java script which I would like to include in all of my

html
pages.

Is there an easy way to include it with a reference or something.

I don't want to have to copy and paste the code to the top of each page
as
if I then change the code I have to go through all pages to change it.

Any help would be appreciated.

I don't know a great deal about javascript or html but know a fair bit

about
other programming languages.

Thanks in advance

--

Jamie Allison
Sheffield Hallam University
Software Engineering
Final Year


Place the JavaScript code in a file (e.g. "yourfile.js") then use:

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

in the <head> section of your Web page.

Jul 23 '05 #4
"Jamie" <ja**********@hotmail.com> wrote in message
news:_1**************@newsfe5-win.ntli.net...
Just had a thought.

My java code has 3 function which I call on the HTML page. Is there any
particular way I have to call the function now it is included this way
instead of the code directly there?

Such as javascrips.ja/MM_swapImgRestore()

previously just called by MM_swapImgRestore()

Regards


No changes are necessary to call function contained in an included
javascript file.

Your js file should not have the following:

<script language="JavaScript">
<!--
Javascript functions here
//-->
</script>
Jul 23 '05 #5
Thanks a million.

All working now.

:-)

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:b6********************@comcast.com...
"Jamie" <ja**********@hotmail.com> wrote in message
news:_1**************@newsfe5-win.ntli.net...
Just had a thought.

My java code has 3 function which I call on the HTML page. Is there any
particular way I have to call the function now it is included this way
instead of the code directly there?

Such as javascrips.ja/MM_swapImgRestore()

previously just called by MM_swapImgRestore()

Regards


No changes are necessary to call function contained in an included
javascript file.

Your js file should not have the following:

<script language="JavaScript">
<!--
Javascript functions here
//-->
</script>

Jul 23 '05 #6
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:b6********************@comcast.com...
"Jamie" <ja**********@hotmail.com> wrote in message
news:_1**************@newsfe5-win.ntli.net...
Just had a thought.

My java code has 3 function which I call on the HTML page. Is there any particular way I have to call the function now it is included this way instead of the code directly there?

Such as javascrips.ja/MM_swapImgRestore()

previously just called by MM_swapImgRestore()

Regards
No changes are necessary to call function contained in an included
javascript file.

Your js file should not have the following:

<script language="JavaScript">


<script type="text/javascript">

The language attribute has been deprecated.
<!--
Not required.
Javascript functions here
//-->
Not required.
</script>


--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #7

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

Similar topics

5
by: cooldv | last post by:
i have many *.html* pages with the same header. i wanted to make one *header* file and put a link to that file in all html pages. So if i ever need to make changes in the header, i will need to...
4
by: juglesh | last post by:
please comment on the following methods of preventing cross site scripting and/or other nastiness: 1: $pages = array('home','contact','about','links' ); // could also build this array with...
10
by: EnjoyNews | last post by:
I have a php site I have an include line called "include 'Cookie.php';" In this Cookie.php file I have these codes. <?php $conn = mysql_connect("$db", "$user", "$pass");...
8
by: David | last post by:
As very often is the case a web page has a main, dynamic content page and a surrounding, more constant "frame" (not html frame!) for stuff like menu, logo, links etc. In my old ASP web pages I...
6
by: jan | last post by:
My apologies for being a javascript beginner and asking such a basic question. This is probably so easy that nobody ever mentions it. Tutorials and places that tell of basic commands never seem to...
2
by: William van Zwanenberg | last post by:
Hi there, I wonder if you guys can help. I'm currently experiencing some coding problems what with trying to use PHP and javascript in tandem. What I'm ultimately trying to achieve is use...
7
by: diane100 | last post by:
Hi I am new to PHP and Smarty (I know only very basic things) and I need help with a warning message I get when I call a page in a browser. I purchased some software from a company who are no...
6
by: =?Utf-8?B?Sm9uYXRoYW4gQXR0cmVl?= | last post by:
Hi I have just taken over management of a web site, many pages of which contain the line: <!--#include virtual="/admin/Includes/conn_Login.asp" --> When I try to load this page (login.asp) I...
25
by: Mark | last post by:
so, i'm making a website. let's say i have header.php, footer.php and content.php. now in index.php I simply want to include the 3 pages. easy enough to do. but let's say the user navigates to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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...

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.