473,508 Members | 3,235 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 16646
On 31 Jul 2006 14:25:44 -0700, "Darrin" <da*********@gmail.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="javascript"
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***@safedataisp.netposted :
>
In my .js file I add write a reference to the external .js file:

document.write('<script type="text/javascript" language="javascript"
^^^^^^^^^^^^^^^^^^^^ 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.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.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
1717
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...
11
8771
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
1724
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...
0
1394
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...
1
3537
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...
19
2217
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...
0
1152
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...
3
12816
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. ...
1
7970
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...
0
7228
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
7128
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
7332
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
7502
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...
0
5635
agi2029
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,...
1
5057
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...
0
4715
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...
0
3206
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...
0
3191
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.