Hello,
This should be a simple question to anyone who knows JavaScript, but I'm new
to it.
I have a JavaScript that I need to use in many pages. How do I create JS
includes?
I tried the standard method - created a text file, then includud it like
this:
<!-------------#Include File="includes/js.txt"------------------->
but this did't work for me.
I would appreciate your advice.
Thank you,
--
Peter Afonin 7 1356
Peter this is how:
<html>
<head>
<title>Test!</title>
<!-- now include script tag with src attribute pointing to -->
<!-- to your script -->
<script language="javas cript" type="text/javascript" src="test.js">
<!-- //
// -->
</script>
</head>
<body>
Hello World!
</body>
</html>
Peter Afonin wrote: Hello,
This should be a simple question to anyone who knows JavaScript, but I'm new to it.
I have a JavaScript that I need to use in many pages. How do I create JS includes?
I tried the standard method - created a text file, then includud it like this:
<!-------------#Include File="includes/js.txt"------------------->
but this did't work for me.
I would appreciate your advice.
Thank you,
Thank you!
I assume that test.js is just a text file that I assign a "js" extension,
correct?
Peter
"Cycloneous Echevarria" <or*****@engr.u conn.edu> wrote in message
news:40******** ******@engr.uco nn.edu... Peter this is how:
<html> <head> <title>Test!</title> <!-- now include script tag with src attribute pointing to --> <!-- to your script --> <script language="javas cript" type="text/javascript" src="test.js"> <!-- //
// --> </script> </head> <body> Hello World! </body> </html>
Peter Afonin wrote:
Hello,
This should be a simple question to anyone who knows JavaScript, but I'm
new to it.
I have a JavaScript that I need to use in many pages. How do I create JS includes?
I tried the standard method - created a text file, then includud it like this:
<!-------------#Include File="includes/js.txt"------------------->
but this did't work for me.
I would appreciate your advice.
Thank you,
"Peter Afonin" <pa**@specialty pulltabs.com> wrote in message
news:10******** *****@corp.supe rnews.com... Thank you!
I assume that test.js is just a text file that I assign a "js" extension, correct?
That is correct.
Thank you!
Peter
"Murray" <pa***@SPAMoffS PAMMER.optusSP4 Mnet.com.au> wrote in message
news:40******** *************** @news.optusnet. com.au... "Peter Afonin" <pa**@specialty pulltabs.com> wrote in message news:10******** *****@corp.supe rnews.com... Thank you!
I assume that test.js is just a text file that I assign a "js"
extension, correct?
That is correct.
> Peter Afonin wrote: I have a JavaScript that I need to use in many pages. How do I create JS includes?
"Cycloneous Echevarria" topposted Peter this is how:
<html> <head> <title>Test!</title> <!-- now include script tag with src attribute pointing to --> <!-- to your script --> <script language="javas cript" type="text/javascript" src="test.js"> <!-- //
// --> </script> </head> <body> Hello World! </body> </html>
A nice bare-bones example. Two remarks on the side: The script element has
no language attribute. It may have had one in the past, but that is history.
To reduce unnecessary webtraffic and in order to "validate", you should
remove the portion which reads <... language="javas cript" ...> from the
script tag. Also, the custom of hiding script from older browsers by
encapsulating the script's content in <!-- --> SGML comments is obsolete.
These "older browsers" that do not know about the script tag, are history
too.
You can also make the src point to a script on another website. Socalled
hit-counters often do this. Simply by entering the whole address, including
http protocol. Just be aware that cross-domain security restrictions apply.
As a last remark, a script element that has a src defined, will ignore any
content inside the tag itself. Only if the source file is not found or there
some other error loading the external script, will the engine consider and
execute any script hardcoded inside the tag.
HTH
Ivo
JRS: In article <10************ *@corp.supernew s.com>, seen in
news:comp.lang. javascript, Peter Afonin <pa**@specialty pulltabs.com>
posted at Fri, 7 May 2004 09:17:37 : I have a JavaScript that I need to use in many pages. How do I create JS includes?
I tried the standard method - created a text file, then includud it like this:
<!-------------#Include File="includes/js.txt"------------------->
but this did't work for me.
Bearing in mind where much system software is written, you should not
expect just one standard for anything.
See <URL:http://www.merlyn.demo n.co.uk/js-nclds.htm>.
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
JRS: In article <40************ ***********@new s.wanadoo.nl>, seen in
news:comp.lang. javascript, Ivo <no@thank.you > posted at Fri, 7 May 2004
22:16:57 : Also, the custom of hiding script from older browsers by encapsulatin g the script's content in <!-- --> SGML comments is obsolete. These "older browsers" that do not know about the script tag, are history too.
You are here making the assumption that the script will be read only by
browsers; that is no more than an assumption.
The master copies of my own web pages are most frequently read by a
tool, CHEKLINX, which is affected by seeing these comment delimiters;
without them, the normally-satisfactory javascript if (b<a) needs
to be re-written as if (b< a) or if (b < a ) .
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joe Mowry |
last post by:
First off, I'm posting this question for a friend that doesn't have
access to the news groups.
Problem:
Using PHP as the base and has several PHP < includes > for various
functions, all this by its self works just fine.
Failure occurs on adding the XML include.
Here's the wierd: If all the PHP includes are removed/commented out,
|
by: Patrick |
last post by:
I have an ASP site with about 50 ASP files, all of which are currently
including a common "includes.asp" file near the top of the file, responsible
for generating the <HEAD/> section of the HTML
I need to make a change for 3 of those ASP files such that some dynamic HTML
is generated in the <HEAD/> section. I want those dynamic HTML to appear
only for 3 specific ASP files. Is there a more elegant way other than to
1) Dim...
|
by: Peter Ammon |
last post by:
A friend was asked "How many ways are there to create an object in C++?"
in an interview. Apparently, the "right" answer was eleven. Does
anyone know how the interviewer arrived at that number? Is this fact
well known (if true)?
|
by: jon wayne |
last post by:
OK!
I had this nagging doubt
Consider (without worrying abt access specifiers)
class Kid : public Parent{...};
Parent::someFunc()
{
Kid k;
}
|
by: Scott Capistrant |
last post by:
I am relatively new to the VB.net platform. How would I
create a packaged exe that can run outside of my computer
(i.e. load the needed dll's and such). Thanks.
| |
by: ANTISPAM_garycnew_ANTISPAM |
last post by:
I am trying to create/update a Php Session with Javascript to confirm
if users have Javascript enabled.
My first thought was to create a Javascript that writes a script tag
referencing a php page, which sets a $_SESSION variable.
javascript.js:
<script type="text/javascript">
<!--//
|
by: martin.zarate |
last post by:
Hey, I'm just trying out the XSD.exe tool and have run into a problem -
it doesn't generate classes for all the members. For example, here's
my call:
D:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin>XSD
D:\projects\Repricer
\Repricer\bin\Debug\Repricer.exe
/outputdir:D:\projects\Repricer\Repricer /t:Mut
ator /t:Source
|
by: etuncer |
last post by:
Hello All,
I have Access 2003, and am trying to build a database for my small
company. I want to be able to create a word document based on the data
entered through a form. the real question is this: can Access create
the document and place it as an OLE object to the relevant table?
Any help is greatly appreciated.
Ricky
|
by: Vallabh |
last post by:
I want to create a separate log that includes an I (logIN) , userid, and date/timestamp from a detailed log. This type of data compresses very well so I can store years of it. I need script to create an separate log files that can saved on each server. Since I dont know much about perl scripting. Your help will be appreciated.
Thanx
Val
|
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...
|
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...
| |
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...
|
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,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |