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

hideDiv, ShowDiv - Javescript ie issue

P: 13
Hello all,

This ones a little different as I'm using some flash actionscript to control the swaping.

The following page uses a hideDiv, ShowDiv Javascript that is working flawlessly in Firefox/PC, Firefox/Mac, Safari/PC, and Safari/Mac but not ie6 or 7. They both have the same issue. They will swap divs once but afterwards all divs are set to hide. Please view the page below and hopefully it will clarify what I mean:

Heres the embeded js:

Expand|Select|Wrap|Line Numbers
  1. <script language=javascript type='text/javascript'> 
  2. function hideDiv(pass) { 
  3. var divs = document.getElementsByTagName('div'); 
  4. for(i=0;i<divs.length;i++){ 
  5. if(divs[i].id.match(pass)){//if they are 'see' divs 
  6. if (document.getElementById) // DOM3 = IE5, NS6 
  7. divs[i].style.visibility="hidden";// show/hide 
  8. else 
  9. if (document.layers) // Netscape 4 
  10. document.layers[divs[i]].display = 'hidden'; 
  11. else // IE 4 
  12. document.all.hideShow.divs[i].visibility = 'hidden'; 
  13. }
  15. function showdiv(pass) { 
  16. var divs = document.getElementsByTagName('div'); 
  17. for(i=0;i<divs.length;i++){ 
  18. if(divs[i].id.match(pass)){ 
  19. if (document.getElementById) 
  20. divs[i].style.visibility="visible"; 
  21. else 
  22. if (document.layers) // Netscape 4 
  23. document.layers[divs[i]].display = 'visible'; 
  24. else // IE 4 
  25. document.all.hideShow.divs[i].visibility = 'visible'; 
  26. </script>

Now the related actionscript, for those who care, looks like this:

Expand|Select|Wrap|Line Numbers
  1. onClipEvent (load) {
  2.     this.onRelease = function() {
  3. getURL("javascript:showdiv('bob')");
  4. getURL("javascript:hideDiv('swap');hideDiv('steve');hideDiv('john');hideDiv('tim')");
  5. };
  6. }
(obviously this is just an example of one instance of the function)

Although I think the issue lies with the JS, as it is the thing I am the least familiar with.

Any thoughts would be excellent and much appreciated!

Jul 29 '08 #1
Share this Question
Share on Google+
5 Replies

P: 13
Sorry neglected two things-

one- I apologize for not wrapping the code in [code] tags. obviously I realized my folly as soon as I hit submit!

two- I did read this related post:

But unsure of where/if I should be changing onclick to onchange

Jul 29 '08 #2

P: 607
Hello Dude, the basic idea behind hiding and showing a component in Javascript is with the use of following two codes.

[HTML] document.getElementById('myTable').style.display = 'none'[/HTML] ---> This code to hide a table with id 'myTable';

[HTML] document.getElementById('myTable').style.display = 'block'[/HTML] ---> This code to show a hidden table with id 'myTable';

Make use of it. If you have any doubts post back it.

Ramanan Kalirajan
Jul 30 '08 #3

P: 13
Hi Ramanan,

Thanks for looking at the code.

So my new javascript code at the top of the doc looks like this:

Expand|Select|Wrap|Line Numbers
  1. <script language=javascript type='text/javascript'> 
  2. function hideDiv(id)
  3. {
  4.    document.getElementById(id).style.display = 'none';
  5. }
  6. function showdiv(id)
  7. {
  8.    document.getElementById(id).style.display = 'block';
  9. }
  10. </script>
So it still works fine in the browers I was checking in except ie6 and ie7. I still get one show/hide, but after the initial show/hide none will work. Heres a link to the updated page:

Do we think it code be the actionscripting I'm using in flash?

Expand|Select|Wrap|Line Numbers
  1. onClipEvent (load) {
  2.     this.onRollOver = function() {
  3.         this.gotoAndPlay("over");
  4.     };
  5.     this.onRollOut = function() {
  6.         this.gotoAndPlay("out");
  7.     };
  8.     this.onRelease = function() {
  9. getURL("javascript:showdiv('swap')");
  10. getURL("javascript:hideDiv('bob');hideDiv('steve');hideDiv('john');hideDiv('tim')");
  11. };
  12. }
I thought it was the JS, but it might be a flash issue, if so I should post this in that forum.

Thanks for any thoughts/help!

Jul 30 '08 #4

P: 607
OK. No Probs. All the best to finish up your work. Any Probs post it in the forum.

Ramanan Kalirajan
Jul 31 '08 #5

Expert Mod 15k+
P: 16,027
One thing you could try is have the divs set to display:none initially in the CSS.

Another thing to try is to make JavaScript calls only without any Flash. That should probably work without problems thus confirming that it is indeed the Actionscript which is causing the problem.
Jul 31 '08 #6

Post your reply

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