[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

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN 
http://www.w3.org/TR/html4/strict.dtd;
html
head
titleExercise 4/title
meta http-equiv=Content-Type content=text/html; charset=utf-8
style type=text/css
.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;
}
/style
script type=text/javascript
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; idxliArr.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; idxliArr.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=;}
/script
/head
body 
pThis doesn't work in Internet Explorer 6. Why and whats the solution?/p
ul id=ul1 
  li id=li11item 1/li 
  li id=li12item 2/li 
  li id=li13item 3 /li 
/ul 
ul id=ul2 
  li id=li21item 1/li 
  li id=li22item 2/li 
  li id=li23item 3 /li 
/ul 
/body
/html


_
What are you waiting for? Join Lavalife FREE
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D30288_t=764581033_r=email_taglines_Join_free_OCT07_m=EXT

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


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

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN
http://www.w3.org/TR/html4/strict.dtd;
html
head
titleExercise 4/title
meta http-equiv=Content-Type content=text/html; charset=utf-8
style type=text/css
.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;
}
/style
script type=text/javascript
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; idxliArr.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; idxliArr.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=;}
/script
/head
body 
pThis doesn't work in Internet Explorer 6. Why and whats the
solution?/p
ul id=ul1 
  li id=li11item 1/li 
  li id=li12item 2/li 
  li id=li13item 3 /li 
/ul 
ul id=ul2 
  li id=li21item 1/li 
  li id=li22item 2/li 
  li id=li23item 3 /li 
/ul 
/body
/html





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]
***


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

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN 
http://www.w3.org/TR/html4/strict.dtd;

html
head
titleExercise 4/title
meta http-equiv=Content-Type content=text/html; 
style type=text/css
.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;
}
/style
script type=text/javascript
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; idxliArr.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; idxliArr.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=;}
/script
/head
body
pThis doesn't work in Internet Explorer 6. Why and whats the 
solution?/p

ul id=ul1
  li id=li11item 1/li
  li id=li12item 2/li
  li id=li13item 3 /li
/ul
ul id=ul2
  li id=li21item 1/li
  li id=li22item 2/li
  li id=li23item 3 /li
/ul
/body
/html



Join Lavalife for free. What are you waiting for? 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D30288_t=764581033_r=email_taglines_Join_free_OCT07_m=EXT

***
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