By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,617 Members | 1,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,617 IT Pros & Developers. It's quick & easy.

difference between IE and FF

P: n/a
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")).fi ndAll(
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")).findAl l( 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?

Dec 27 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
alex wrote:
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/ru...c6a745/?hl=en#
>

--
Fred

Dec 27 '06 #2

P: n/a
Fred said the following on 12/27/2006 6:05 AM:
alex wrote:
>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/comp.lang.javascript/browse_thread/thread/145dcdbddbb78612/b604daea4acaa1a7?lnk=gst&q=loadJSFile&rnum=10#b604 daea4acaa1a7>

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.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 27 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.