473,385 Members | 1,396 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,385 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 6511
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.