473,805 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1257
"Jamie" <ja**********@h otmail.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.j s") then use:

<script type="text/javascript" src="yourfile.j s"></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="JavaS cript">
<!--
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.j s"></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******** ************@co mcast.com...
"Jamie" <ja**********@h otmail.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.j s") then use:

<script type="text/javascript" src="yourfile.j s"></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_swapImgResto re()

previously just called by MM_swapImgResto re()

Regards

"McKirahan" <Ne**@McKirahan .com> wrote in message
news:Mp******** ************@co mcast.com...
"Jamie" <ja**********@h otmail.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.j s") then use:

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

in the <head> section of your Web page.

Jul 23 '05 #4
"Jamie" <ja**********@h otmail.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_swapImgResto re()

previously just called by MM_swapImgResto re()

Regards


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

Your js file should not have the following:

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

All working now.

:-)

"McKirahan" <Ne**@McKirahan .com> wrote in message
news:b6******** ************@co mcast.com...
"Jamie" <ja**********@h otmail.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_swapImgResto re()

previously just called by MM_swapImgResto re()

Regards


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

Your js file should not have the following:

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

Jul 23 '05 #6
"McKirahan" <Ne**@McKirahan .com> wrote in message
news:b6******** ************@co mcast.com...
"Jamie" <ja**********@h otmail.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_swapImgResto re()

previously just called by MM_swapImgResto re()

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

Your js file should not have the following:

<script language="JavaS cript">


<script type="text/javascript">

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


--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript 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
5680
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 edit only 1 file rather than all pages. for *.asp* pages this code works fine:- <!-- #include file="filename.inc" -->
4
1554
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 readdir('MySafeDir') ?? if( in_array($_GET, $pages) ) { include $_GET.".php";} else {die("Nice Try."); }
10
3162
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"); mysql_select_db("$db"); //-------------------------------------------------------------------------- -------------
8
1437
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 solved this by using #include so that each .asp page simply started with including this in the top of the file. Actually it was also ASP code since some of the frame content was dynamically created from the database. I can see many possibilities...
6
1854
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 mention what I want to do. I've looked into SSI, shtml, external javascript, css, and html commands. There seems to be many solutions, but I would like to focus on using the best and easiest solution. I have a website with more than 1000 pages....
2
1934
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 Javascript to access the DOM objects of any given page within the web site I'm building to dyanamically resize any and all text elements. I have Javascript some code that works
7
2694
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 longer replying to my messages for help so I have decided to try and fix the many problems myself. I am receiving the following messages when loading any of my pages and some pages are not even showing at all. Warning:...
6
4002
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 get the error: Page cannot be displayed Active Server Pages, ASP 0126 (0x80004005) The include file '/admin/Includes/conn_Login.asp' was not found.
25
2272
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 mysite.com/content.php. now the header and footer will appear to be missing. so now the question is, how can i include the header and footer in content.php only if the page isn't already nested?
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10107
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7649
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
6876
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
5544
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
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.