Results 1 to 4 of 4
  1. #1
    jmchaffie is offline Member
    Join Date
    Oct 2008
    Posts
    2
    Rep Power
    0

    Default Cross-Browser Issue with show/hide divs

    Hello everyone. I've searched for this answer for a long time now, but it's coming down to the wire and I'm not very good at java yet, so here is what I have below. It works great in FF and Opera, but in IE it just simply does not work properly.

    Java Code:
    <!---- stack_flip.js - modified from online sources -->
    
    function showOrHide(eId, state) 
    {
     	if (e = document.getElementById(eId)) 
    	{
    	   if (state == null) 
    	   {
    	   	  state = e.style.display == 'none';
    		  e.style.display = (state ? '' : 'none');
    	   }
    	   if (eId == "box1") { hideAll1() }
    	   if (eId == "box2") { hideAll2() }
    	   if (eId == "box3") { hideAll3() }
    	   if (eId == "box4") { hideAll4() }
    	}
    }
    
    function hideAll1(){
    	document.getElementById('box1').style.display = 'table';
    	document.getElementById('box2').style.display = 'none';
    	document.getElementById('box3').style.display = 'none';
    	document.getElementById('box4').style.display = 'none';
    }
    function hideAll2(){
    	document.getElementById('box1').style.display = 'none';
    	document.getElementById('box2').style.display = 'table';
    	document.getElementById('box3').style.display = 'none';
    	document.getElementById('box4').style.display = 'none';
    }
    function hideAll3(){
    	document.getElementById('box1').style.display = 'none';
    	document.getElementById('box2').style.display = 'none';
    	document.getElementById('box3').style.display = 'table';
    	document.getElementById('box4').style.display = 'none';
    }
    function hideAll4(){
    	document.getElementById('box1').style.display = 'none';
    	document.getElementById('box2').style.display = 'none';
    	document.getElementById('box3').style.display = 'none';
    	document.getElementById('box4').style.display = 'table';
    }
    
    <!--------------------------------->
    I'm sure this looks familiar, I have modified this code from many examples I've found online to expand / retract divs on a page. I added the 'hidAll(x)()' functions to create the illusion of all other items collapsing upon opening one item.

    Like I said, this works fantabulous in FF and Opera. in IE it will only allow back and forth clicking on single items, otherwise display goes south.

    I have researched this as a problem having something to do with the getElementById, but I just can't figure it out no matter how I rewrite this.

    Thank you very much for any time and advice you could offer.

    Sincerely,
    John

    Java Code:
    <!-------- HTML call snippet ------->
    <a style="text-decoration:none" href="javascript:;" onclick="showOrHide('box4')"  class="itemLink" style="text-align:justify">
    <font face="Arial" color="maroon" size="3"><b>Important information</b><br></a>
    <div id="box4" style="display:none; WIDTH: 300px">
        <!-- update an iframe in center of page -->	 	  
        <div style="z-index: 19; left: 288px; width: 510px; position: absolute; top: -130px; height: 120px">
    	<iframe src="open_notes.html" width="510" height="1050" scrolling="no" frameborder="0">
    	</iframe> 
        </div>
        <!-- end iframe -->
    <ul>
    <li>List of important sub-stuff</li>
    <li>More sub-stuff</li>
    </ul>
    </div>
    <!----------------------------->
    Last edited by jmchaffie; 10-21-2008 at 03:44 PM.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  3. #3
    jmchaffie is offline Member
    Join Date
    Oct 2008
    Posts
    2
    Rep Power
    0

    Default

    It would be about the above java script in question. I sincerely apologize if by your question, that means this is the incorrect forum to post this. I have simply come to wits end and am looking for help.

    If you can recommend someplace else for me to go I would appreciate that also. I mean no harm here. I am only looking for some insight.

    I've been a web designer for some time now, and the changes of what will/won't work on what browser over the years has been a pain to say the least. Java has always seemed to be pretty constant for me, and that is why I chose this method to perform the effect I was looking for.

    Since I know little about Java vs. Java Script, other than the practical applications where I've used the .js or inline scripts on my websites, I do not have a functional vocabulary or methodology to approach you from other than my own although I will answer any question you have to the best of my ability.

    Thank you,
    John

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by Incumearrem View Post
    Whats up everyone. Im new to www.java-forums.org. Nice to meet you all!
    Hi welcome to Java-Forums.

    Please do not hijack others thread. If you have a question select the most suitable sub-forum and post your question there. You may banned, if you are not pay your attention on that.

Similar Threads

  1. JAVA a cross-platform language? I have my doubts!
    By willemjav in forum Advanced Java
    Replies: 34
    Last Post: 10-24-2008, 11:26 PM
  2. Collapse all Divs
    By LWCARAB in forum New To Java
    Replies: 1
    Last Post: 04-15-2008, 06:42 PM
  3. Issue related to browser
    By sachindanayak in forum Java Servlet
    Replies: 0
    Last Post: 02-03-2008, 02:25 AM
  4. netbeans 6.0 not show commpunent or show blank page
    By fahimaamir in forum NetBeans
    Replies: 1
    Last Post: 01-26-2008, 06:20 AM
  5. To hide browser heading
    By priyanka_t in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 01-09-2008, 07:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •