[Javascript] code generator doesn't load script

David T. Lovering dlovering at gazos.com
Thu Mar 20 14:39:34 CST 2003


Bizarre.  About the only comment I can make is that when code behaves differently
on consecutive occassions, one of several things are happening:

  (1)	The window is refreshing, but the code and the variables within it are not
		[i.e; the difference between clicking the 'reload' button, and simply hitting
		the refresh (Meta-5) key].  This gives the code 'memory' of the state it is
 		in, and any additional input may push it into a new state.

  (2)	Since JavaScript runs primarily at the client end, and Active-X et al run
		primarily at the server end, the loading process tends to give precidence
		to the server end.  In other words, if the server-driven code has the equivalent
		of a code-handler for the 'onLoad' event, and the client-side JavaScript has a
		'onLoad' declaration, the server-side code will win.  Normally this isn't a
		problem, but if the two code modules are each attempting to do something that
		will interfere with the other, this is bad news for the JavaScript code.

  (3)	Object initialization is a somewhat complicated process, and building a scrollbar
		by means of a new object declaration may not work reliably in every instance,
		particularly where variables from outside are used to steer what values/labels are
		used for the option entries.  This can be managed easily when everything is pre-
		declared, but can be problematic when a "race" condition exists between the creation
        of the variables you are relying on, and the screen update which displays them.
        Remember -- this is a virtual multi-threaded process, and many things are happening
        at the same time.

		To see what can go wrong, build two pull-downs, where the entry in the first determines
		the options that appear in the second.  Now hit the 'refresh' button, and note that
		the 'slave' menu does not always correctly display the correct dependent variables
		corresponding to the final value in the primary window.  [One of Microsoft's many
		blunders is in the fact that they didn't correctly implement the 'onChange' routine
		with respect to selection menus].

  (4)	To avoid the issues in (3), try building the pull-down with explicit JavaScript statements, as
		in

			document.myForm.myMenu.options.length = 0;
            document.myForm.myMenu.options[0] = new Option("who", "");
            document.myForm.myMenu.options[1] = new Option("what", "");
            document.myForm.myMenu.options[2] = new Option("why", "");
            document.myForm.myMenu.options[3] = new Option("where", "");
            document.myForm.myMenu.options[4] = new Option("when", "");
        
        If this works, and the other doesn't, I'm inclined to think that the
        array-driven constructor is at fault.

    -- Dave Lovering

"Muchacho, Laurent (TWIi London)" wrote:
> 
> Hi Len
> 
> I had a look to your page and it seems that the error occur only when you
> launch the window because when it's open and you refresh your scroller work
> This make me think simply that the browser is calling your object before the
> browser had time to load the js file.
> 
> Laurent
> 
> ps:this is only a guess and I'm not sure completely this is what's happening
> I wait to see what David T.Lovering have to says for this one maybe after 10
> confusing email he will have explain it.
> 
> -----Original Message-----
> From: Dierickx, Len (ESAS) [mailto:len.dierickx-eds at eds.com]
> Sent: 20 March 2003 12:03
> To: '[JavaScript List]'
> Subject: [Javascript] code generator doesn't load script
> 
> Hi there,
> 
> I am creating a code generator for some cut-n-paste code I wrote, to avoid
> to many questions about it.
> The problems goes like this:
> 
> A page with a form generates the object ang gives this object:
> 
> var my= new scrollerObj('my','150','100','3','100','content in
> here','333333','777777','1',[1,"none","#000000"],[2,"none","#ffffff"]);
> 
> This is written in a script tag.
> The object responds to the script loaded in hte head with this
> <script type="text/javascript" src="js/ooscroller.js"></script>
> doesn't work as it should, after that I added the code directly to the page
> but that doesn't change a thing.
> When I open a window using javascript, the first time the code is written to
> the new window, loads the ooscroller.js file (checked with a document.write
> at the end of the code) but it doesn't show the scroller >
> 
> Error on page
> Lie: 10
> Char: 1
> 'scrollerObj' is undefined.
> code: 0
> 
> second time you push the button both scrollers are written to the javascript
> opened window, the error remains but it works.
> 
> Check the code on http://n.one.port5.com/generator_v1.3.html
> 
> tnx for checking,
> 
> Len Dierickx
> 
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> DISCLAIMER - The preceding e-mail message (including any attachments)
> contains information that may be confidential, may be protected by the
> attorney-client or other applicable privileges, or may constitute non-public
> information.  It is intended to be conveyed only to the designated
> recipient(s) named above.  If you are not an intended recipient of this
> message, or have otherwise received it in error, please notify the sender by
> replying to this message and then delete all copies of it from your computer
> system.  Any use, dissemination, distribution, or reproduction of this
> message by unintended recipients is not authorized and may be unlawful. The
> contents of this communication do not necessarily represent the views of
> this company.
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dlovering.vcf
Type: text/x-vcard
Size: 304 bytes
Desc: Card for David T. Lovering
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20030320/3adecfda/attachment.vcf>


More information about the Javascript mailing list