Please can someone tell me why this script isn't working in IE7? It works in Firefox and Opera. EDIT: When you click 'heading' more content should then show. <script type="text/javascript"><!-- function dsp(loc){ if(document.getElementById){ var foc=loc.firstChild; foc=loc.firstChild.innerHTML? loc.firstChild: loc.firstChild.nextSibling; foc.innerHTML=foc.innerHTML==''?'':''; foc=loc.parentNode.nextSibling.style? loc.parentNode.nextSibling: loc.parentNode.nextSibling.nextSibling; foc.style.display=foc.style.display=='block'?'none':'block';}} if(!document.getElementById) document.write('<style type="text/css"><!--\n'+ '.more_content{display:block;}\n'+ '//--></style>'); //--></script> Code (markup):
Are you suppose to see this heading I saw the same thing in Firefox as well as IE 7. Looks ok for me.
This works in Firefox and in IE7: <script type="text/javascript"><!-- function dsp(loc){ if(document.getElementById){ var foc=loc.firstChild; foc=loc.firstChild.innerHTML? loc.firstChild: loc.firstChild.nextSibling; // foc.innerHTML=foc.innerHTML==''?'':''; foc=loc.parentNode.nextSibling.style? loc.parentNode.nextSibling: loc.parentNode.nextSibling.nextSibling; foc.style.display=foc.style.display=='block'?'none':'block';}} if(!document.getElementById) document.write('<style type="text/css"><!--\n'+ '.more_content{display:block;}\n'+ '//--></style>'); //--></script> PHP:
Here's an improved version: <script type="text/javascript"><!-- function dsp(loc){ if(document.getElementById){ var foc=loc.firstChild; foc=loc.firstChild.innerHTML? loc.firstChild: loc.firstChild.nextSibling; var th = document.getElementById(loc); if(th != null){ th.innerHTML=th.innerHTML==''?'':''; // foc.innerHTML=foc.innerHTML==''?'':''; } foc=loc.parentNode.nextSibling.style? loc.parentNode.nextSibling: loc.parentNode.nextSibling.nextSibling; foc.style.display=foc.style.display=='block'?'none':'block';}} if(!document.getElementById) document.write('<style type="text/css"><!--\n'+ '.more_content{display:block;}\n'+ '//--></style>'); //--></script> PHP:
Thanks for your help WebGyver, can you confirm it loads fine in FF and IE for you now? Do you see the image? http://www.murraysworld.com/test.php
Can you show me a test page or something? Looking at the link you have at the top of this thread, I can't see a difference between IE and FF. However, if I understand you correctly, this might help: if(!document.getElementById) document.write('<style type="text/css"><!--\n'+ '.more_content{display:block;overflow:auto;}\n'+ '//--></style>'); PHP:
With some messing around it seems to go away but thanks for that new code, I'll use it if the problem comes back. Can you confirm it loads fine in FF and IE for you now? Do you see the image? http://www.murraysworld.com/test.php