473,238 Members | 3,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,238 software developers and data experts.

defer attribute on script element not working in firefox 1.0

The following does not work in firefox:

<script defer="defer">

var x=document.getElementsByName("repositoryNamespace" )
alert(x.length + " elements!")
</script>

</head>

<body id="www.interoperabilityframework.info">
<a name="repositoryNamespace"></a>
</body></html>

I have also tried the following:
<script src="reference.js" defer="defer">

</script>

</head>

<body id="www.interoperabilityframework.info">
<a name="repositoryNamespace"></a>
which does not work either, except for in IE.

I have tried without defer="defer" and just having defer on the
element,
I have tried with defer = True or true.
I have tried it with and without a dtd.
IE seems to accept everything, Firefox nothing.

Interestingly enough, using the xhtml 1.0 dtd Firefox accepted an
onLoad attribute on the body. But gee, I don't want to use the onLoad
attribute, I want to defer the script.

Jul 23 '05 #1
3 6504
well I've gone ahead and used the window.onload event to call my
script, would still like to have a defer attribute that worked however.

Jul 23 '05 #2
On 21/03/2005 10:22, pantagruel wrote:
The following does not work in firefox:

<script defer="defer">


It won't effect execution, however the type attribute is required. In
a HTML document, the above should be

<script type="text/javascript" defer>

As for whether defer "works" or not, the attribute is only a hint. In
fact, all the hint means is "this script won't modify the document".
Without it, a user agent must execute the script immediately because
it might have to output data to the document stream. With it, the user
agent can do what it likes: parse the script immediately, or ignore it
until a more convenient time. It doesn't mean "wait until the document
is loaded". That's what the load event is for.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3
pantagruel wrote:
The following does not work in firefox:

<script defer="defer">

Exactly what does 'work' mean to you? Here is what the HTML
spec says:

"When set, this boolean attribute provides a hint to the user
agent that the script is not going to generate any document
content (e.g., no "document.write" in javascript) and thus,
the user agent can continue parsing and rendering."

<URL:http://www.w3.org/TR/html4/interact/scripts.html#adef-defer>

var x=document.getElementsByName("repositoryNamespace" )
alert(x.length + " elements!")
</script>

</head>
[...]
I have also tried the following:
<script src="reference.js" defer="defer">
</script>
</head>

<body id="www.interoperabilityframework.info">
<a name="repositoryNamespace"></a>

which does not work either, except for in IE.
Again, depends on your idea of what 'does not work'.

I have tried without defer="defer" and just having defer on the
element,
I have tried with defer = True or true.
I have tried it with and without a dtd.

IE seems to accept everything, Firefox nothing.

Interestingly enough, using the xhtml 1.0 dtd Firefox accepted an
onLoad attribute on the body. But gee, I don't want to use the onLoad
attribute, I want to defer the script.


You infer that the 'defer' attribute should stop the script from
being parsed until after the document has finished loading, but
the HTML 4.01 spec does not say that.

The way I read it, defer says the browser *may* defer processing
the script and to start parsing subsequent elements because the
script does not, in the programmer's opinion, affect document
layout.

It is by no means a directive to leave the script until after
the page has load.

If you want the behaviour of onload, use onload. Don't expect
defer to do what you want simply because it's what you want.

Have you considered putting your script into the document body,
just below the element it refers to?

<body id="www.interoperabilityframework.info">
<a name="repositoryNamespace"></a>
<script type="text/javascript">
var x=document.getElementsByName("repositoryNamespace" )
alert(x.length + " elements!")
</script>

Note that x.length should only ever be either 0 or 1, as the
name attribute on 'a' elements must be unique in the document
and shares the same namespace as the id attribute.
--
Fred
Jul 23 '05 #4

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

Similar topics

2
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...
1
by: arnold | last post by:
Hi, I've been knocking my head against the wall trying to create an XSL transform to perform "normalizations" of a set of XML files that have a common structure. % XML file before transform
4
by: petermichaux | last post by:
Hi, I'm hoping for a reason I'm wrong or an alternate solution... I'd like to be able to dynamically include some javascript files. This is like scriptaculous.js library but their solution is...
2
by: Muzzy | last post by:
Hi, I've used information on these newsgroups to build many pages. So I thought that now that I have my script working (something that I've been working on for about a week), I should post it so...
3
by: 张韡武 | last post by:
Hello. I am a newbie trying to get my first XLST script working. I already know how to do this: Source XML: <category id="a0104"> <name>Oil and Gas</name> </category> XSLT: <xsl:for-each...
6
by: Toby Inkster | last post by:
Does anyone have any idea why this effect using script.aculo.us is working in Opera, but not Firefox? http://examples.tobyinkster.co.uk/Balloons2/Balloon%20tooltip.html (I've not had the...
11
by: npm | last post by:
Hi, I'm trying to add an IF statement to this javascript that will select/display only those xml nodes either with a certain attribute or attribute value. Here's my xml code: <stations>...
2
by: npm | last post by:
Hi, I've been racking my head and searching the net (and these forums) to try and get around this problem. I have radio stations stored in an xml file (each state has their own xml file). I'm able...
5
by: =?Utf-8?B?bXBhaW5l?= | last post by:
So this one is confusing as everything works but I want this warning to go away. This is what I have (within a .NET 2.0 Web Application, using VS.NET 2008 SP1): default.aspx: <%@ Page...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.