Re: [WSG] Javascript Code not working in IE6

2007-10-23 Thread Kevin Lennon

Alexander Uribe wrote:
   



In my javascript class at college, I have to find out why this piece 
of code does not run in IE6.

I can't seem to figure out why.
If anyone knows, that would be great

cheers,

Alex.

Code below

"http://www.w3.org/TR/html4/strict.dtd";>



Exercise 4


.borders {
border: 1px solid red;
width: 150px;
}

.li_borders {
background: yellow;
border: 1px solid blue;
color: red;
}
.li2_borders {
background: blue;
color: white;
}
#ul2 {
xwidth: 150px;
}

#ul2 li {
border-color: silver;
border-style: solid;
border-width: 1px 1px 0px 1px;
display: inline;
font-weight:bold;
margin: 0;
padding: 0 4px;
}


window.onload = init;
function init()
{
var liArr = new Array();
var idx;
//--- process first UL block
var id = document.getElementById("ul1");
id.addEventListener("mouseover", ul1on, false);
id.addEventListener("mouseout", ul1off, false);
liArr = id.getElementsByTagName("li");
for(idx=0; idxfunction li_s()  { alert(this.innerHTML); } 
function li_on() { 
document.getElementById(this.id).className="li_borders";}
function li_off(){ document.getElementById(this.id).className="";}
function li2_on() { document.getElementById(this.id).className="li2_borders";}
function li2_off(){ document.getElementById(this.id).className="";}



This doesn't work in Internet Explorer 6. Why and whats the 
solution?


  item 1
  item 2
  item 3 


  item 1
  item 2
  item 3 






Join Lavalife for free. What are you waiting for? 


***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
***


No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.8/1088 - Release Date: 10/23/2007 1:26 PM
  
Does it have anything to do with the fact that Line 22 #ul2 Property 
xwidth doesn't exist : 150px even if that is not actually JavaScript?



***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
***begin:vcard
fn:Kevin Lennon
n:Lennon;Kevin
org:Lake Area Webs
adr:;;227 Fire Tower Road;Milford;PA;18337;United States of America
email;internet:[EMAIL PROTECTED]
title:Web Design & Developer
tel;home:570-296-3865
url:http://www.lakeareawebs.com
version:2.1
end:vcard




RE: [WSG] Javascript Code not working in IE6

2007-10-23 Thread Focas, Grant
IE does not support the W3C addEventListener, it uses attacheEvent so
you need a cross-browser way to attach events. Here's one:

 

function attachEventListener(target, eventType, functionRef, capture){

  // function can be called with a pointer or a string representing
a function name

  if (typeof(functionRef)== 'string') {

functionRef=eval(functionRef);

  }

  if (typeof target.addEventListener != "undefined"){

target.addEventListener(eventType, functionRef, capture);

  } else if (typeof target.attachEvent != "undefined"){

target.attachEvent("on" + eventType, functionRef);

  } else {

eventType = "on" + eventType;

if(typeof target[eventType] == "function"){

var oldListener = target[eventType];

target[eventType] = function(){

oldListener();

return functionRef();

};

}else{

target[eventType] = functionRef;

}

  }

}

 



From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Alexander Uribe
Sent: Wednesday, 24 October 2007 10:09 AM
To: wsg@webstandardsgroup.org
Subject: [WSG] Javascript Code not working in IE6

 




In my javascript class at college, I have to find out why this piece of
code does not run in IE6.
I can't seem to figure out why.
If anyone knows, that would be great

cheers,

Alex.

Code below

http://www.w3.org/TR/html4/strict.dtd";>


Exercise 4


.borders {
border: 1px solid red;
width: 150px;
}

.li_borders {
background: yellow;
border: 1px solid blue;
color: red;
}
.li2_borders {
background: blue;
color: white;
}
#ul2 {
xwidth: 150px;
}

#ul2 li {
border-color: silver;
border-style: solid;
border-width: 1px 1px 0px 1px;
display: inline;
font-weight:bold;
margin: 0;
padding: 0 4px;
}


window.onload = init;
function init()
{
var liArr = new Array();
var idx;
//--- process first UL block
var id = document.getElementById("ul1");
id.addEventListener("mouseover", ul1on, false);
id.addEventListener("mouseout", ul1off, false);
liArr = id.getElementsByTagName("li");
for(idx=0; idx<liArr.length; idx++ ) {
liArr[idx].addEventListener("click", li_s, false);
liArr[idx].addEventListener("mouseover", li_on, false);
liArr[idx].addEventListener("mouseout", li_off, false);
}
//--- process second UL block
id = document.getElementById("ul2");
liArr = id.getElementsByTagName("li");
for(idx=0; idx<liArr.length; idx++ ) {
liArr[idx].addEventListener("click", li_s, false);
liArr[idx].addEventListener("mouseover", li2_on, false);
liArr[idx].addEventListener("mouseout", li2_off, false);
}
}
function ul1on() { document.getElementById("ul1").className="borders";}
function ul1off(){ document.getElementById("ul1").className="";}
function li_s()  { alert(this.innerHTML); }  
function li_on() {
document.getElementById(this.id).className="li_borders";}
function li_off(){ document.getElementById(this.id).className="";}
function li2_on() {
document.getElementById(this.id).className="li2_borders";}
function li2_off(){ document.getElementById(this.id).className="";}


 
This doesn't work in Internet Explorer 6. Why and whats the
solution?
 
  item 1 
  item 2 
  item 3  
 
 
  item 1 
  item 2 
  item 3  
 







Join Lavalife for free. What are you waiting for?
<http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Flavalife9%2Eninemsn%2Ec
om%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26
locale%3Den%5FAU%26a%3D30288&_t=764581033&_r=email_taglines_Join_free_OC
T07&_m=EXT> 


***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
***

**
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**


***
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
***


[WSG] Javascript Code not working in IE6

2007-10-23 Thread Alexander Uribe
 



In my javascript class at college, I have to find out why this piece of code 
does not run in IE6.
I can't seem to figure out why.
If anyone knows, that would be great

cheers,

Alex.

Code below

http://www.w3.org/TR/html4/strict.dtd";>


Exercise 4


.borders {
border: 1px solid red;
width: 150px;
}

.li_borders {
background: yellow;
border: 1px solid blue;
color: red;
}
.li2_borders {
background: blue;
color: white;
}
#ul2 {
xwidth: 150px;
}

#ul2 li {
border-color: silver;
border-style: solid;
border-width: 1px 1px 0px 1px;
display: inline;
font-weight:bold;
margin: 0;
padding: 0 4px;
}


window.onload = init;
function init()
{
var liArr = new Array();
var idx;
//--- process first UL block
var id = document.getElementById("ul1");
id.addEventListener("mouseover", ul1on, false);
id.addEventListener("mouseout", ul1off, false);
liArr = id.getElementsByTagName("li");
for(idx=0; idx