Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-21-2012, 01:34 AM   PM User | #1
eydg
New Coder

 
Join Date: Sep 2012
Posts: 72
Thanks: 2
Thanked 1 Time in 1 Post
eydg is an unknown quantity at this point
ie incompatibility

Could you please identify, why this piece doesn't work with internet explorer6
while it works in chrome, firefox and opera?
ey

Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">


<body onLoad="ST()" >
<center>
  <table  border="0">
    <tbody>
      <tr>
        <td><form name="item">
            <pre>&nbsp;</pre>
            <table border="0" cellspacing="0" cellpadding="0"
width=1000px>
              <tr>
                <td height="89">&nbsp;</td>
              </tr>
              <tr>
                <td height="82"><p>toy
                  <input type="TEXT" name="a" size="20" value=""
id="okno">
                  </p>
                  <p> 
                    <input type="button" value=" UP " 
              
              onClick="dawaj()">
                    <input type="button" value=" DOWN " 
              
              onClick="dawaj2()">
                </p></td>
              </tr>
              <tr>
                <td height="78">&nbsp;</td>
              </tr>
            </table>
            <center>
            </center>
          </form>
          
    </tbody>
  </table>
</center>
<script> 
n=1;

function
SH(v){zz=v.length;for(i=1;i<(zz);i++){y=r(zz);x=r(zz);z=v[y];v[y]=v[x];v[x
]=z}}
function ST(){SH(item);b=item.length;}

function dawaj(){
n=n+1; if (n>b-1){n=1}
if(item[n]==null){n=0};x=item[n];v=new 
Array;x=x+"|";i=0;while(x.length>1){l=x.substring(0,x.indexOf("|"));v[i]=l
;i++;x=x.substring(x.ind
exOf("|")+1)};

document.item.a.value=v[0]; 
}

function dawaj2(){
//
n=n-1;if (n<1){n=b-1}	
if(item[n]==null){n=0};x=item[n];v=new 
Array;x=x+"|";i=0;while(x.length>1){l=x.substring(0,x.indexOf("|"));v[i]=l
;i++;x=x.substring(x.ind
exOf("|")+1)};

document.item.a.value=v[0]; 
}


function r(){}


item=new Array("",
"boy|strong|brave",
"girl|pretty|smart",
"dog|furry|friendly"
);

</script>
</body>
</html>
eydg is offline   Reply With Quote
Old 11-21-2012, 01:53 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,244
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
You really CARE about IE6???

Most of us have about given up on even IE7, since it is so old. IE6 is really getting ancient.

However...

It just MIGHT help if you told us WHAT doesn't work.

As it is, we have no way of knowing, since most of us no longer have IE6 to test it with.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is online now   Reply With Quote
Old 11-21-2012, 02:34 AM   PM User | #3
Logic Ali
Regular Coder

 
Logic Ali's Avatar
 
Join Date: Sep 2010
Location: London
Posts: 961
Thanks: 0
Thanked 198 Times in 193 Posts
Logic Ali will become famous soon enoughLogic Ali will become famous soon enough
The code as posted is full of illegal line breaks, and so won't run anywhere.
Once formatted you'll see that the IE error console indicates 'object doesn't support this action'.
It soon becomes clear that it doesn't like the reference to item, which in I.E. is a global object. Call it something else.
Logic Ali is offline   Reply With Quote
Old 11-21-2012, 03:18 AM   PM User | #4
eydg
New Coder

 
Join Date: Sep 2012
Posts: 72
Thanks: 2
Thanked 1 Time in 1 Post
eydg is an unknown quantity at this point
Yes, these sure are valid points. It appears my ie is 7 (so also dated) but the point is that I am facing problems with making an app names siteinfile transform my page into an exe. I instantly connected it with the errors in ie, which do not manifest themselves in chrome, firefox adn opera, admittedly, newer.

Here's the code without the line breaks, and "item" changed to "Sache".


I may gave undertaken a wrong approach in assuming that seasoned js coders would catch any flaws in the code like this, and this is what my question is about: is the JS piece of code written properly?

While in chrome the buttons switch between three kinds of toys, in ie7 they take no effect - nothing shows up.


Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">


<body onLoad="ST()" >
<center>
  <table  border="0">
    <tbody>
      <tr>
        <td><form name="sache">
            <pre>&nbsp;</pre>
            <table border="0" cellspacing="0" cellpadding="0"
width=1000px>
              <tr>
                <td height="89">&nbsp;</td>
              </tr>
              <tr>
                <td height="82"><p>toy
                  <input type="TEXT" name="a" size="20" value=""
id="okno">
                  </p>
                  <p> 
                    <input type="button" value=" UP " 
              
              onClick="dawaj()">
                    <input type="button" value=" DOWN " 
              
              onClick="dawaj2()">
                </p></td>
              </tr>
              <tr>
                <td height="78">&nbsp;</td>
              </tr>
            </table>
            <center>
            </center>
          </form>
          
    </tbody>
  </table>
</center>
<script> 
n=1;

function
SH(v){zz=v.length;for(i=1;i<(zz);i++){y=r(zz);x=r(zz);z=v[y];v[y]=v[x];v[x
]=z}}
function ST(){SH(sache);b=sache.length;}

function dawaj(){
n=n+1; if (n>b-1){n=1}
if(sache[n]==null){n=0};x=sache[n];v=new Array;x=x+"|";i=0;while(x.length>1){l=x.substring(0,x.indexOf("|"));v[i]=l
;i++;x=x.substring(x.indexOf("|")+1)};

document.sache.a.value=v[0]; 
}

function dawaj2(){
//
n=n-1;if (n<1){n=b-1}	
if(sache[n]==null){n=0};x=sache[n];v=new 
Array;x=x+"|";i=0;while(x.length>1){l=x.substring(0,x.indexOf("|"));v[i]=l
;i++;x=x.substring(x.indexOf("|")+1)};

document.sache.a.value=v[0]; 
}


function r(){}


sache=new Array("","boy|strong|brave","girl|pretty|smart","dog|furry|friendly");

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

Last edited by eydg; 11-21-2012 at 03:21 AM..
eydg is offline   Reply With Quote
Old 11-21-2012, 04:34 AM   PM User | #5
Logic Ali
Regular Coder

 
Logic Ali's Avatar
 
Join Date: Sep 2010
Location: London
Posts: 961
Thanks: 0
Thanked 198 Times in 193 Posts
Logic Ali will become famous soon enoughLogic Ali will become famous soon enough
Still you ignore the error console. Rename the form element (and the references to it) to something different to any global variable.

Proof:
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">


<body onLoad="ST()" >
<center>
  <table  border="0">
    <tbody>
      <tr>
        <td><form name="xsache">
            <pre>&nbsp;</pre>
            <table border="0" cellspacing="0" cellpadding="0"
width=1000px>
              <tr>
                <td height="89">&nbsp;</td>
              </tr>
              <tr>
                <td height="82"><p>toy
                  <input type="TEXT" name="a" size="20" value=""
id="okno">
                  </p>
                  <p> 
                    <input type="button" value=" UP " 
              
              onClick="dawaj()">
                    <input type="button" value=" DOWN " 
              
              onClick="dawaj2()">
                </p></td>
              </tr>
              <tr>
                <td height="78">&nbsp;</td>
              </tr>
            </table>
            <center>
            </center>
          </form>
          
    </tbody>
  </table>
</center>
<script> 
n=1;

function
SH(v){zz=v.length;for(i=1;i<(zz);i++){y=r(zz);x=r(zz);z=v[y];v[y]=v[x];v[x
]=z}}
function ST(){SH(sache);b=sache.length;}

function dawaj(){
n=n+1; if (n>b-1){n=1}
if(sache[n]==null){n=0};x=sache[n];v=new Array;x=x+"|";i=0;while(x.length>1){l=x.substring(0,x.indexOf("|"));v[i]=l
;i++;x=x.substring(x.indexOf("|")+1)};

document.xsache.a.value=v[0]; 
}

function dawaj2(){
//
n=n-1;if (n<1){n=b-1}	
if(sache[n]==null){n=0};x=sache[n];v=new 
Array;x=x+"|";i=0;while(x.length>1){l=x.substring(0,x.indexOf("|"));v[i]=l
;i++;x=x.substring(x.indexOf("|")+1)};

document.xsache.a.value=v[0]; 
}


function r(){}


sache=new Array("","boy|strong|brave","girl|pretty|smart","dog|furry|friendly");

</script>
</body>
</html>
Logic Ali is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:18 PM.


Advertisement
Log in to turn off these ads.