473,585 Members | 2,657 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reference a .js file from another .js file

I've seen a couple threads on this that did not answer my question and
I could not add a post to them.

I've inherited a web application that is going to be replaced in the
coming months. For the time being, I would like to add the Analytics
(Urchin) script to the page, but there is no common components for the
100's of pages in the site. There is however a common javascript file
that is referenced from all of the pages.

I would like to be able to add the script for the Google Analytics
tracker to this .js file, and it would automatically be added to every
page, although the script references another .js file.

How can I reference this external javascript file from inside an
existing javascript file?

Any help would be greatly appreciated.

Thanks,
-Darrin

Jul 31 '06 #1
3 16652
On 31 Jul 2006 14:25:44 -0700, "Darrin" <da*********@gm ail.comwrote:
>I've seen a couple threads on this that did not answer my question and
I could not add a post to them.

I've inherited a web application that is going to be replaced in the
coming months. For the time being, I would like to add the Analytics
(Urchin) script to the page, but there is no common components for the
100's of pages in the site. There is however a common javascript file
that is referenced from all of the pages.

I would like to be able to add the script for the Google Analytics
tracker to this .js file, and it would automatically be added to every
page, although the script references another .js file.

How can I reference this external javascript file from inside an
existing javascript file?

Any help would be greatly appreciated.

Thanks,
-Darrin
Darrin,
I'm not sure if this is what you're looking for, but if you need
to add a reference to another script inside of an existing one, I've
accomplished this in the past using the following:

In my .js file I add write a reference to the external .js file:

document.write( '<script type="text/javascript" language="javas cript"
src="http:/somedomain/javascript/standard.js"></script>')
I can then access any objects, etc.. from the external script.
Hope this helps.

Matt
Jul 31 '06 #2
I was going to try that, but I read on some other posts that it did not
work and had some "system-wide impacting" results. ;-)

I will certainly give that a try. That should work perfectly for me.

Thank you!

-Darrin

Jul 31 '06 #3
JRS: In article <sm************ *************** *****@4ax.com>, dated
Mon, 31 Jul 2006 17:35:56 remote, seen in news:comp.lang. javascript,
Matt Ratliff <ma***@safedata isp.netposted :
>
In my .js file I add write a reference to the external .js file:

document.write ('<script type="text/javascript" language="javas cript"
^^^^^^^^^^^^^^^ ^^^^^ 1
>src="http:/somedomain/javascript/standard.js"></script>')
^\ 2

1 - Deprecated/superfluous
2 - Desirable

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/>? JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Aug 1 '06 #4

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

Similar topics

6
1724
by: John Reese | last post by:
def uselessHash(filename): fp= open(filename) hash= 0 for line in fp: hash ^= hash(line.strip()) fp.close() # do I need this or is fp closed by ref count? return hash Consider the function above. Do I need the fp.close(), or will the file be closed automatically when fp goes out of scope and its
11
8793
by: Vanessa | last post by:
Hi, I would like to know whether there's any way for me to pass an object by reference to another form? Regards Vanessa
1
1732
by: Ben | last post by:
I am having trouble calling functions in another file.. Lets look at the scenario below: File xyz.cc: (I have both xyz.h and xyz.cc, for simplicity I've avoided xyz.h) ------------ struct xyz { int x, y, z; }; xyz readxyz (fstream& inFile) {
0
1396
by: Beda Christoph Hammerschmidt | last post by:
Hello, i have a user defines type which consists of an integer and a reference to another user defined type: connect to SHOP ; create type BestPostenTyp as( menge integer, artikel ref(ArtikelTyp), mode db2sql;
1
3544
by: DjordjeD | last post by:
I need to call(reference) class member "PrintDestination.PrintDestinationPrinter" from another file. How do I do it, I tried "ReportRenderer.PrintDestination.PrintDestinationPrinter" but it doesn't work. Please help! here is my class: *****************************************
19
2229
by: **Developer** | last post by:
When I get the image from the file the file remains locked so the Delete fails with a "used by another process" So I tried using a clone and disposing the obtained image. But that didn't fix the problem. Can you help?
0
1165
by: cor | last post by:
In Access(97) I am able to have a cell to be a hyperlink referencing a spreadsheet, a cell, a column or a database's table or query. When I click on it It opens on such reference program. The content of such cell is not the content of the reference but a 'display text' value that I assign. Since the database does not see the referenced value...
3
12831
by: maheshkadam | last post by:
Hi friends I am new to perl so please guide me. I have one application which created backup log file every day.But it appends that file so you can see logs for different day in one file only. My requirement is to copy backup log for the specific day (yesterday) and write in other file. That file will be mailed to admin for ready reference....
1
7984
by: titli | last post by:
Hi All, Both of my mdbs were developed in Access 2002. Till yesterday two of the mdbs were opening and working fine. But today one of the mdbs is throwing the error below when the user tried opening it. Error message 1 Your Microsoft Access database or project contains a missing or broken reference to the file <filename>.
0
7908
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...
0
8336
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...
1
7950
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...
0
8212
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...
0
5389
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...
0
3835
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...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2343
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
1
1447
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.