473,785 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

loading script dynamically in Mozilla

hi.

I load a script dynamically and it works
* everytime with IE6.
* sometimes! with Mozilla1.5 <- makes me curious
* never with Opera7.11
all tests on WindowsXP.

With "sometimes" I mean
[reload->fail][reload->fail][reload->succeed][reload->fail][reload->fail][reload->fail][reload-succceed][reload->fail]
etc. until it sometimes loops.

How I do:
In the page I call:
var oElement = document.create Element("SCRIPT ");
oElement.id = "myscriptid ";
oElement.src = "scripts/common.js";
document.body.a ppendChild(oEle ment);
And then I call a function in the file by just calling
myTestFunction( );

I can live with that it works or not works but not Sometimes in
Mozilla! (Also: the myTestFunction just contains an alert and
sometimes this one starts to loop so I have to shoot down Mozilla.

TIA

/OF
Jul 20 '05 #1
2 2211


Ola Fjelddahl wrote:
I load a script dynamically and it works
* everytime with IE6.
* sometimes! with Mozilla1.5 <- makes me curious
* never with Opera7.11
all tests on WindowsXP.

With "sometimes" I mean
[reload->fail][reload->fail][reload->succeed][reload->fail][reload->fail][reload->fail][reload-succceed][reload->fail]
etc. until it sometimes loops.

How I do:
In the page I call:
var oElement = document.create Element("SCRIPT ");
oElement.id = "myscriptid ";
oElement.src = "scripts/common.js";
document.body.a ppendChild(oEle ment);
And then I call a function in the file by just calling
myTestFunction( );
There is no guarantee that the browser waits till the file common.js is
loaded and parsed before it process the next line with
myTestFunction( )
so that could be a reason for the error.
I can live with that it works or not works but not Sometimes in
Mozilla! (Also: the myTestFunction just contains an alert and
sometimes this one starts to loop so I have to shoot down Mozilla.


What does "fail" mean, do you get a script error when calling
myTestFunction?

An alert is a modal dialog that blocks the browser thus it is not a good
tool if you want to debug things that happen repeatedly.
Let the function output some text to the page (a textarea or use the DOM
to add some text) and the problem might go away.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
hi.

Thanks for answering.

Inline.

I load a script dynamically and it works
* everytime with IE6.
* sometimes! with Mozilla1.5 <- makes me curious
* never with Opera7.11
all tests on WindowsXP.
With "sometimes" I mean
[reload->fail][reload->fail][reload->succeed][reload->fail]
[reload->fail][reload->fail][reload->fail][reload->succeed]
[reload->fail]
etc. until it sometimes loops.
How I do:
In the page I call:
var oElement = document.create Element("SCRIPT ");
oElement.id = "myscriptid ";
oElement.src = "scripts/common.js";
document.body.a ppendChild(oEle ment);
And then I call a function in the file by just calling
myTestFunction( );
There is no guarantee that the browser waits till the file common.js is
loaded and parsed before it process the next line with
myTestFunction( )
so that could be a reason for the error.
I have tried both running them (loading js-file and calling) both
after each other and with a delay. Say I have a button for calling
the function; first I load the page and then I wait a second and then
I call the function by pressing the button. Sometimes works,
sometimes not.
So I don't believe it has to do with the time for loading the script
file.

I havn't found a way to retrieve the text for dynamically added
scripts either.

I can live with that it works or not works but not Sometimes in
Mozilla! (Also: the myTestFunction just contains an alert and
sometimes this one starts to loop so I have to shoot down Mozilla.

What does "fail" mean, do you get a script error when calling
myTestFunction?
Right. The function does not exist.
And by looping I mean that the messagebox popus up again as soon as i
click it away.

An alert is a modal dialog that blocks the browser thus it is not a good
tool if you want to debug things that happen repeatedly.
Let the function output some text to the page (a textarea or use the DOM
to add some text) and the problem might go away.


Tried that too. Great advice though.
I have come to suspect that there is a bug in Mozilla (never thought I
would write that in a public forum and still don't) due to the
irregular behaviour.
But since Opera won't ever work I have decided on a less sexy
solution.

If there are any Mozilla coders out there, please throw me a line and
I will see if I can make a small page to repeat the behaviour.

[ ol***********@d iespammers.mand ator.com ]
/OF
Jul 20 '05 #3

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

Similar topics

1
3533
by: David | last post by:
Hi, I use the following page code to open a popup window - it works OK, but whilst the popup is loading you can see the URL in the title of the popup until it's fully loaded and then the title changes to whatever I put in the <TITLE></TITLE> Any way to force the popup to display the <TITLE> whilst the page loads? Thanks
11
2844
by: Wentink | last post by:
Does anybody have a simple script that let's me popup a picture from a thumbnail? The ones i found are all very very complicated and messy in the source... Thanks, Tintin
10
2199
by: Randy Webb | last post by:
This page: http://www.hikksworld.com/loadJSFiles/ Is one where I was testing the ability of browsers that can/can't dynamically load a JS file with one of the three methods: 1)Changing the src property of a script tag. 2)Inserting a script src="" tag in a div via innerHTML 3)Using document.createElement to add a script element. The fourth method on the page is writing a script tag to a layer, and to the best of my knowledge it only...
5
2781
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 navigation that has onMouseOver and onMouseOut triggers, that use function calls in my external .js file. When I mouseOver a button in my navigation quickly enough to catch it before the rest of the body loads, it returns a function "not defined"...
7
5066
by: cjl | last post by:
Hey all: I've searched the newsgroup, and googled, but I'm stuck. I want to be able to 'dynamically' add a .js file to a web page after the page has loaded, based on user interaction. For example, the user make a choice by clicking on an item called 20050928, and as a result a file named "20050928/case.js" is "included", and the data contained within is available.
17
2786
by: CES | last post by:
All, I was wondering if their is a way of loading an external script fill from within a script?? <script language="javascript" type="text/javascript"> function test(var){ <script language="javascript" src="../scripts/base.js" type="text/javascript" /> } </script> Obviously this would cause n error but this would give you an idea of what I'm looking to do. I know I can do this with a simple include but...
1
3811
by: ozzy.osborn | last post by:
Hello All, I have been struggling with a cross browser solution to loading external javascript files on the fly. I have been successful using the following code in IE6: var newScr = document.createElement("SCRIPT"); newScr.src = "newScr.js"; newScr.type="text/javascript";
2
3215
by: boczek | last post by:
Hello all. I'm writing a small async webapp. in JavaScript and I'm using <script> element technique to load data. I'm usign <scriptbecause of cross domain restrictions with XmlRequest. The problem is when I remove a element that is currently loading from DOM (with removeChild) Firefox still loads it and waits with other scripts.
5
5126
by: Pete Marsh | last post by:
Wondering if anyone can recomend some sample code for dynamically loading the GD module. I have tried setting the extension dir in php.ini, and loading the GD module from there when apache is started, but it won't load. There is also the option of dynamically loading the module at run time of the script. LD() i believe is the call.
0
10162
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
9959
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...
0
8988
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, 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...
1
7509
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
6744
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
5396
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
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4061
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
3
2893
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 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...

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.