Jump to content

getattribute() not working in IE 6.0


robert_gsfame

Recommended Posts

function open(x)

{

if(document.getElementById('img2'+x).getAttribute('src')=="image/button2.gif")

  {

    document.getElementById('img2'+x).setAttribute('src','image/buttonclose2.gif');

    document.getElementById('img1'+x).setAttribute('src','image/buttonclose1.gif');

    document.getElementById("mytable"+x).style.display="";

  }else

    if(document.getElementById('img2'+x).getAttribute('src','image/buttonclose2.gif'))

      {

        document.getElementById('img2'+x).setAttribute('src','image/button2.gif');

        document.getElementById('img1'+x).setAttribute('src','image/button1.gif');

        document.getElementById("mytable"+x).style.display="none";

      }

}

 

those script works well in FF but when i try in IE 6.0 not working at all....

how can i get those work for both browsers

 

thx

 

i thought that IE 6.0 doesnt support getattribute and setattribute

Link to comment
https://forums.phpfreaks.com/topic/208888-getattribute-not-working-in-ie-60/
Share on other sites

I try changing into this

 

if(document.getElementById('img2'+x).src = 'image/button2.gif')

  {

    document.getElementById('img2'+x).src = 'image/buttonclose2.gif';

    document.getElementById('img1'+x).src = 'image/buttonclose1.gif';

    document.getElementById('mytable'+x).style.display="";

  }else

if(document.getElementById('img2'+x).src = 'image/buttonclose2.gif')

  {

    document.getElementById('img2'+x).src = 'image/button2.gif';

    document.getElementById('img1'+x).src = 'image/button1.gif';

    document.getElementById('mytable'+x).style.display="none";

    }

}

 

almost solved, but the toggle only open and cannot close....as if the bold part Else{} not read

 

function open(x) {
var argSrc = document.getElementById('img2'+x).src;
var img1 = document.getElementById('img1'+x).src
var mytable = document.getElementById('mytable'+x).style.display;

if(argSrc == 'image/button2.gif') {
    argSrc = 'image/buttonclose2.gif';
    img1 = 'image/buttonclose1.gif';
    mytable = "block";
}
if(argSrc == 'image/buttonclose2.gif') {
     argSrc = 'image/button2.gif';
     img1 = 'image/button1.gif';
     myTable ="none";
}
}

Try this out

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.