difference between IE and FF

A

alex

my html page like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>script.aculo.us Autocompleter functional test file</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src="../../lib/prototype.js" type="text/javascript"></script>
<script src="../../src/scriptaculous.js"
type="text/javascript"></script>
<script src="../../src/unittest.js" type="text/javascript"></script>
<style type="text/css" media="screen">
.selected { background-color: #888; }
</style>
<script>
var a=document.getElementsByTagName("script");
alert(a.length);
alert(a[0].src);
alert(a[1].src);
//alert(a[2]);
var arr=$A(document.getElementsByTagName("script")).findAll(
function(s) {
//alert(s.src);
return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/))
});
//alert(arr[0]);
</script>
</head>
when executed in IE and FF,I get different results.
in IE,when alert(a.length) get 9,
in FF,when alert(a.length) get 2.
i look into scriptaculous.js,code like this:
var Scriptaculous = {
Version: '1.6.2',
require: function(libraryName) {
// inserting via DOM fails in Safari 2.0, so brute force approach
document.write('<script type="text/javascript"
src="'+libraryName+'"></script>');
},
load: function() {
if((typeof Prototype=='undefined') ||
(typeof Element == 'undefined') ||
(typeof Element.Methods=='undefined') ||
parseFloat(Prototype.Version.split(".")[0] + "." +
Prototype.Version.split(".")[1]) < 1.5)
throw("script.aculo.us requires the Prototype JavaScript
framework >= 1.5.0");

$A(document.getElementsByTagName("script")).findAll( function(s) {
return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/))
}).each( function(s) {
var path = s.src.replace(/scriptaculous\.js(\?.*)?$/,'');
var includes = s.src.match(/\?.*load=([a-z,]*)/);
(includes ? includes[1] :
'builder,effects,dragdrop,controls,slider').split(',').each(
function(include) { Scriptaculous.require(path+include+'.js')
});
});
}
}

Scriptaculous.load();
above code will dynamically generate tag <script>.....
i think i should be 9 instead of 2.
anyone can give your opinion?
 
F

Fred

alex said:
my html page like this: [...]
Scriptaculous.load();
above code will dynamically generate tag <script>.....
i think i should be 9 instead of 2.
anyone can give your opinion?

In Firefox, getElementsByTagName doesn't work properly if used in the
head as the docment loads with dynamically created script elements.
Also, the scriptaculous "loader" script is crap. Try this thread for a
solution:

<URL:
http://groups.google.com.au/group/rubyonrails-spinoffs/browse_frm/thread/8ba4881087c6a745/?hl=en#
 
R

Randy Webb

Fred said the following on 12/27/2006 6:05 AM:
alex said:
my html page like this: [...]
Scriptaculous.load();
above code will dynamically generate tag <script>.....
i think i should be 9 instead of 2.
anyone can give your opinion?

In Firefox, getElementsByTagName doesn't work properly if used in the
head as the docment loads with dynamically created script elements.
Also, the scriptaculous "loader" script is crap. Try this thread for a
solution:

All of that to simply load a .js file? Why make it so difficult?

<URL:
http://groups-beta.google.com/group...lnk=gst&q=loadJSFile&rnum=10#b604daea4acaa1a7>

How much simpler can it get to load a .js file on the fly? And, it
doesn't matter if it is during page load or after.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top