By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 995 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

Simple Script - No Errors on Moz.(checked log) - IE Object Required Error

P: 2
Hi can anyone help with this little problem. I have a simple script to
swap between two divs on a page. It works perfectly in Firefox & Safari
& Opera. It fails in IE 6 giving Object Required error on initializing
second variable var layer2. I can't get to the bottom of this. Can
anyone help?

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript"> 
  2. function showhide(element) { 
  3.    var layer1 = document.getElementById('layer1').style; 
  4.    var layer2 = document.getElementById('layer2').style; 
  5.    if (element == "php"){ 
  6.      layer1.visibility= "hidden"; 
  7.      layer2.visibility= "visible"; 
  8.    } 
  9.    else if (element == "java") { 
  10.      layer2.visibility= "hidden"; 
  11.      layer1.visibility= "visible"; 
  12.    } 
  13.  
  14. </script> 
  15.  
[HTML]
<div id="layer1" style="visibility:visible">
<a href="javascript:showhide('php');">Click here for some PHP
examples</a>
....</div>
<div id="layer2" style="visibility:hidden">
<a href="javascript:showhide('java');">Click here to see Java
examples</a>
....</div>
[/HTML]

Thanks. Matt
Dec 31 '06 #1
Share this Question
Share on Google+
5 Replies


ronverdonk
Expert 2.5K+
P: 4,258
You must have something else causing this. This code runs perfectly well in IE 6.

Ronald :cool:
Dec 31 '06 #2

P: 43
This code also works fine in IE 8.
Jan 1 '07 #3

P: 2
Hi, I got to the bottom of the problem. It was IE not recognising my valid XHTML. I used a <applet ..../> tag instead of <applet...> </applet> this fixed the problem. Thanks for your replies. Apparently no version of IE can understand XHTML
Jan 2 '07 #4

b1randon
Expert 100+
P: 171
Hi, I got to the bottom of the problem. It was IE not recognising my valid XHTML. I used a <applet ..../> tag instead of <applet...> </applet> this fixed the problem. Thanks for your replies. Apparently no version of IE can understand XHTML
Ohhh burn! nice. Thanks for posting your solution, so many ppl forget to if they solve their own problem.
Jan 2 '07 #5

P: 37
Ohhh burn! nice. Thanks for posting your solution, so many ppl forget to if they solve their own problem.

Yeah, I was going to suggest to check the way you close your tags.

I had a professor that made us validate everything before submitting any homework assignment.
Jan 2 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.