[thelist] xml in javascript ie does show it

Jeff Howden jeff at jeffhowden.com
Sat Oct 22 20:38:47 CDT 2005


Hi,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: gruppenfreizeit
> 
> My page2 is reloading each second.
> The prob is to recall a function after page2 is reloaded.
> 
> page2 sets some elements into page1
> 
> while($o<$cnt){
> if(somethingHappens){
> 		print 'var y = x.createElement("TR");';
> 		print 'var el = x.createElement("TD");';
> 
> 		print 'el.onclick=function(){do something;};';
> 
> 		print 'y.appendChild(el);';	
> 		print 'tbl.appendChild(y);';
> }}
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

First, build the page out *without* using whatever server-side language
you're using.  Then, you can see if the culprit is something being added or
altered by your server-side code or not.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> This runs well in Mozilla, IE stopped doing the function 
> after one click. 
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

What steps have you taken to confirm that IE is no longer executing the
function after the even fires the first time?

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> Further on mouseover and mouseout events have been very 
> instabil in IE 6.x
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

This is something else I've never personally had any issues with.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> Next fact is Mozilla is much more tolerant in different
> codes.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

Actually, I think the opposite is true.  Mozilla is very intolerant of
certain invalid markup while IE is very forgiving, often "fixing" the markup
prior to rendering it so that it can at least be rendered.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> Like IE needs the TR element to display the tablerows.
> Mozilla not. [...]
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

Then Mozilla is ignoring the spec because a TR element is a required table
element.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> [...] Then Mozilla always works if I use
> setAttribute("onlick",
> "function myfunction(do something)") [...]
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

That's not valid code, no matter which browser.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> [...] el.onclick=function(){do somthing}; 
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

I've never experienced any difficult using this approach provided I'm
referring to an event handler IE supports for the element I'm working with.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> or want to set style elements as attributes. 
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

Yes, there are issues with that in IE, granted.  However, there is a valid
alternative to using the setAttribute() method.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> How can I call a function, which is coded in page1 ?	
> print 'el.onclick=function myfunction();'; is not
> working.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

If the function is already defined, then you can call it like this:

el.onclick = myfunction;

Notice the lack of parenthesis.  If you *have* to pass arguments to your
function, then you'll need to do it like this:

el.onclick = function()
{
  myfunction(somevar, somevar2);
}

If you're still struggling with this, put something online and shoot thelist
a message with a link to it.

 [>] Jeff Howden
     jeff at jeffhowden.com
     http://jeffhowden.com/




More information about the thelist mailing list