473,509 Members | 10,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Defer the call of an external .js file

Hi

I want to defer the call of an external .js file so that when the link
in the page is clicked, the .js file is downloaded and
included in the page. The link would also pass on some arguments to
the function in the page. Once the .js file is successfully
downloaded/included, I would then like to pass on the arguments from
this function to the function
that is within the .js file and call the function that's inside the
..js file from the function in the page. Is this possible ? Here's the
sort of thing that I've tried but I get "Is not defined errors"
presumably because the function in the .js file hasn't been
incorporated into the page after clicking the link.
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function dload(id,name,street)
document.write('<script src="whatever.js"><\/script>');
jsfunction(id,name,street)
</SCRIPT>
</head>
<body>
<a href="javascript:dload('12345','john','Westwood St');">Link</a>
</body>
</html>

thanks
Jim
Jul 23 '05 #1
2 2260
Jim Adamson wrote on 15 dec 2004 in comp.lang.javascript:
I want to defer the call of an external .js file so that when the link
in the page is clicked, the .js file is downloaded and
included in the page.


Make two similar pages, one with, one without the .js

However such belated loading is never necessary,
as immediate loading and clever programming suffice.

I suppose you are ready for some serverside programming.

;-}

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #2
Jim Adamson wrote:

I want to defer the call of an external .js file so that when the link in the page is clicked, the .js file is downloaded and
included in the page.


The appropriate word here is 'load' - you don't call files.

Just use an ordinary link. All browsers afaik will dump imported files
with mimetype 'application/x-javascript' right into the JavaScript
execution environment without disturbing the loaded page, regardless of
file extension, allowing dynamically assembled files - '.php', '.asp',
'.jsp' e.g. - to be accessed as well.

Jul 23 '05 #3

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

Similar topics

5
2763
by: danny.myint | last post by:
I was under the assumption that javascript loads all the <head></head> elements before processing the <body> tag in Mozilla/Netscape/Firefox. It doesn't seem like it, with my problem. I have...
3
6520
by: pantagruel | last post by:
The following does not work in firefox: <script defer="defer"> var x=document.getElementsByName("repositoryNamespace") alert(x.length + " elements!")
0
7126
by: Dave Sisk | last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table. (Note this is an external trigger defined with the ADDPFTRG CL command, not a SQL trigger defined with the CREATE...
9
11554
by: keith | last post by:
I created a class libery which has name space Assembly and class Assembly and compiled it. Then created a C# project and called a method in the external class e.g. Assembly dll;...
2
4744
by: PrettySneaky | last post by:
I have bumbed into a frustrating problem with my webservice. When I run he web site in Visual studio 2005 everything works fine. But when i try to publish it, it seems to be unable to call a method...
2
2403
by: John J. Lee | last post by:
I was cheered to see that this guy claims to have solved the problem with onload only firing very late: http://dean.edwards.name/weblog/2005/09/busted/ However, "ash" comments on that...
4
3156
by: dennise9 | last post by:
My exeternal JS works fine when the call is placed in the page head or body. But if I call the same javascript from a (clicked) text link on the page, the script throws a JS error when it...
2
2295
by: kirkox | last post by:
Hi guys, this is my first post. I am a newbie, of course. The question is really simple: how can I call functions from an external file in a new js file and work with its method? Thank in...
7
2248
progdoctor
by: progdoctor | last post by:
I have a php web based application with dhtml menu. Each time user click menu Item, the page loads external php page into a div container in that page and then load external javascript as the...
0
7237
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
7137
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
7347
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
7506
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
5656
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
5062
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
4732
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
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
443
bsmnconsultancy
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...

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.