PDA

View Full Version : TabPanel's problem,the scripts don't work in IE,Help!



hahaEr2003
20 May 2007, 8:04 PM
TabPanel's problem,the scripts don't work in IE,Help!
For a sample test,change the EXT/examples/tabs/tabs.html 。
get EXT/examples/tabs/tabs-example.js file,and seek this code:


var tab2 = jtabs.addTab('jtabs-2', "Ajax Tab 1");
var updater = tab2.getUpdateManager();
updater.loadScripts=true; //this code is add by myself,for test scripts's working
updater.setDefaultUrl('ajax1.htm');
tab2.on('activate', updater.refresh, updater, true);

and add this code in ajax1.html

<script type="text/javascript">
<!--
alert("Hello!script!");
//-->
</script>


It's work in FF,but can't work in IE6,
who can help me?

ismoore
21 May 2007, 12:07 AM
is there any particular reason for the <!-- -> comments as they serve no function whatsoever? if you remove them does that help?

hahaEr2003
21 May 2007, 12:57 AM
thank u,I test this code like u said,the js code work will.but if the html has css,It can't work.
may I create a tabpanel use iframe,and how?

ismoore
21 May 2007, 1:02 AM
is it only IE that is not recognising the CSS? It is never something I had tried though I know that FF interprets CSS. Could you post a bit more of an example?

hahaEr2003
21 May 2007, 1:49 AM
I try to use code like this:


//repeat create Tab
Ext.each(tmpItems,function(Item){

var iframe = jtabs.el.createChild({tag: 'iframe', border:0,frameborder: 0, src: Item.URL});
var tab2 = jtabs.addTab(iframe, Item.name);

var updater = tab2.getUpdateManager();
updater.loadScripts=true; //这句很重要!!!!
updater.setDefaultUrl(Item.URL);
tab2.on('activate', updater.refresh, updater, true);


});

but,it's still no work!not only ie ,but also ff
the tab's html code like this:


<!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=gb2312">
<title>Hello World Dialog Example</title>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="../../../sbui.css"/>

<script type="text/javascript" src="../../adapter/yui/yui-utilities.js"></script>
<script type="text/javascript" src="../../adapter/yui/ext-yui-adapter.js"></script>


<script type="text/javascript" src="../../ext-all.js"></script>

<script language="javascript">
var selCompare= new (function(){

this.init=function(){
Ext.MSG.alert("Hello!");
};
});
Ext.onReady(selCompare.init, selCompare, true);


</script>


</head>
<body>


the error like this:
Ext is not defined
[Break on this error] Ext.onReady(selCompare.init, selCompare, true);

it's seem that the js file can't load in iframe,
how to soluate it?

Animal
21 May 2007, 2:05 AM
iframes don't need an UpdateManager, there's no "loadScripts". They are semi-independent browser windows.

ismoore
21 May 2007, 2:22 AM
just to recap back to the original problem:
TabPanel's problem,the scripts don't work in IE,Help!
You could not get the javascript working in the loaded page but now that works.
However I assume that in the page you were trying to load into a tab had some CSS in it that did not seem to work when the page was loaded and for that reason you are now looking at iFrames.
Is the CSS just not making the changes you expect or does it conflict with some existing styles?
If you are loading this into a panel of the main document, is it possible to include the CSS as part of the "top level" page and hence avoid the need for the iFrame?
Ian

Animal
21 May 2007, 2:49 AM
CSS is ignored when content is dynamically loaded. It must go in the top level page.

ismoore
21 May 2007, 3:15 AM
ok, I think this is a bit of a grey area for browsers. FF seems to load the css as I had a problem that took me ages to track down where a page was generating an exception in tomcat. As this was being loaded by ajax somewhere else on the page, the CSS styles included on thaterror page suddenly changed the layout of my existing page! ( I think I was using innerHTML but I cannot remember to be exact)

that said - bottom line, don't load CSS dynamically!

thanks