PDA

View Full Version : Do not set body.innerHTML='' if scripts are loaded in body



vtswingkid
19 Feb 2007, 12:20 PM
If I move all the scripts into the head all is well.
All is well in netscape and firefox as is.
Problem is most of the css is lost in IE and Opera.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<link rel='stylesheet' type='text/css' href='ext/resources/css/ext-all.css' />
<script type='text/javascript' src='ext/yui-utilities.js'></script>
<script type='text/javascript' src='ext/ext-all.js'></script>
<script type='text/javascript' src='ext/ext-bridge-yui.js'></script>
<script type='text/javascript'>
Main = function(){
var layout;
return{
Init:function(){
document.body.innerHTML='';
layout = new Ext.BorderLayout(document.body,{
north:{
initialSize: 50
},
west:{
split: true,
initialSize: 150,
minSize: 100,
maxSize: 300,
titlebar: true,
animate: true
},
center:{
tabPosition: 'top',
closeOnTab: true,
alwaysShowTabs: true,
resizeTabs: true
}
});
layout.beginUpdate();
layout.add('north', new Ext.ContentPanel('header',{autoCreate:true}));
layout.add('west', new Ext.ContentPanel('menu',{autoCreate:true, title:'Menu'}));
layout.add('center', new Ext.ContentPanel('home',{autoCreate:true, title:'Home'}));
layout.endUpdate();
}
}
}();
Ext.onReady(Main.Init);

</script>
</body>
</html>


Oh, let me double check that this works on the .40 release.

EDIT:

Was wrong this isn't working in .40 release...

JeffHowden
19 Feb 2007, 12:26 PM
It probably should fail as you're trying to reference tags (script and style) that may only be placed in the head in a document with a strict doctype.

tryanDLS
19 Feb 2007, 12:30 PM
Does the strict DTD enforce putting script in the head tag only?

vtswingkid
19 Feb 2007, 12:37 PM
I removed the document strict line at the top.... Same result.
I also tried it with


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">

vtswingkid
19 Feb 2007, 12:51 PM
The problem is:


document.body.innerHTML='';

I guess IE and Opera must wipe out the script files that were loaded into the body.
Firefox does not.

Well it has nothing to do with alpha 1.0...
But for future reference don't erase the body if you are putting scripts in it.