robert_gsfame Posted July 26, 2010 Share Posted July 26, 2010 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 More sharing options...
Zane Posted July 26, 2010 Share Posted July 26, 2010 instead of getAttribute('src') Try just using src instead. e.g document.getElementById('img2'+x).setAttribute('src','image/buttonclose2.gif'); to document.getElementById('img2'+x).src = 'image/buttonclose2.gif'; Link to comment https://forums.phpfreaks.com/topic/208888-getattribute-not-working-in-ie-60/#findComment-1091129 Share on other sites More sharing options...
haku Posted July 26, 2010 Share Posted July 26, 2010 And please use code tags around your code. Link to comment https://forums.phpfreaks.com/topic/208888-getattribute-not-working-in-ie-60/#findComment-1091130 Share on other sites More sharing options...
robert_gsfame Posted July 26, 2010 Author Share Posted July 26, 2010 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 Link to comment https://forums.phpfreaks.com/topic/208888-getattribute-not-working-in-ie-60/#findComment-1091131 Share on other sites More sharing options...
Zane Posted July 26, 2010 Share Posted July 26, 2010 On your IF statements, you need two equals signs for comparison (==) Link to comment https://forums.phpfreaks.com/topic/208888-getattribute-not-working-in-ie-60/#findComment-1091134 Share on other sites More sharing options...
robert_gsfame Posted July 26, 2010 Author Share Posted July 26, 2010 i've tried that but that makes both open and close not working Link to comment https://forums.phpfreaks.com/topic/208888-getattribute-not-working-in-ie-60/#findComment-1091136 Share on other sites More sharing options...
Zane Posted July 26, 2010 Share Posted July 26, 2010 What about this part document.getElementById("mytable"+x).style.display=""; Shouldn't display be set to something besides nothing..... like block. Link to comment https://forums.phpfreaks.com/topic/208888-getattribute-not-working-in-ie-60/#findComment-1091138 Share on other sites More sharing options...
robert_gsfame Posted July 26, 2010 Author Share Posted July 26, 2010 nothing wrong with that i think..because although i remove that part, the same problem still occured Link to comment https://forums.phpfreaks.com/topic/208888-getattribute-not-working-in-ie-60/#findComment-1091139 Share on other sites More sharing options...
Zane Posted July 26, 2010 Share Posted July 26, 2010 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 Link to comment https://forums.phpfreaks.com/topic/208888-getattribute-not-working-in-ie-60/#findComment-1091143 Share on other sites More sharing options...
robert_gsfame Posted July 26, 2010 Author Share Posted July 26, 2010 really makes me mad.... i try this var button2=new Image(); button2.src="image/button2.gif"; then put it into the if condition and it works well thx Zanus for your help! Link to comment https://forums.phpfreaks.com/topic/208888-getattribute-not-working-in-ie-60/#findComment-1091144 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.