iframe / Javascript hell!!!

Post May 9th, 2008, 9:02 am

Hello all.

In a nutshell

I have a script which draws information from a MSSQL table, dumps into a JavaScript array.
JavaScript then shows the results, allowing for Filters / Orders and Pagination to be applied without page reload.

I then have a iframe and Div which is hidden (dislay: none)

When I click on a link, it runs some javascript which changes the display to block
  1.  
  2. document.getElementById('MyIFrame').style.display = "block";
  3.  


This works great.

Then I have a link, which runs javascript which simply does
  1.  
  2. parent.document.getElementById('MyIFrame').style.display = "none";
  3.  


The problem is, in FF (Both 2 and 3), when the Iframe is hidden, it reloads the iframe.
I know this as the Iframe calls a JavaScript function which currently has an alert, which pops up AFTER I have hidden the iframe.

NOTE:
If I comment out that one which hides the iframe, it works fine (except the iframe still showing)

WHY IS THIS HAPPENING!!!!

The code is very long and complex so if you want to see, please state what part.

Cheers in advance
Heal your mind, and the body will follow
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post May 9th, 2008, 9:02 am

  • dimat
  • Student
  • Student
  • User avatar
  • Joined: 02 Aug 2006
  • Posts: 66
  • Loc: Kiev, Ukraine
  • Status: Offline

Post May 10th, 2008, 2:55 pm

try to put in a div, and hide div instead of iframe
Let it be beer...

Post May 11th, 2008, 3:19 am

I would do that but when the div is loaded, I am grabbing some results from MSSQL.
Thus, using the iframe, allows me to reload that page to get the data, without pulling all the records.
Heal your mind, and the body will follow

Post May 12th, 2008, 1:10 am

I have drilled down the code to be limited and narrow the problem, I still do not know WHY this is happening or how to stop it.

CODE OF MAIN PAGE

  1.  
  2.  
  3. <script type='text/javascript'>
  4. function OpenIframe(){
  5.     document.getElementById("MyIframe").style.display="block";
  6.     document.getElementById("MyIframe").src = "test_iframe.asp";
  7. }
  8. </script>
  9.  
  10. <iframe id='MyIframe' src='' style='display:none;'></iframe>
  11.  
  12. <a href='#' onclick='OpenIframe();'>Open IFrame</a>
  13.  


CODE OF IFRAME

  1.  
  2.  
  3. <script type='text/javascript'>
  4. alert("The Iframe has loaded");
  5.  
  6. function CloseIframe(){
  7.     parent.document.getElementById("MyIframe").src = "";
  8.     parent.document.getElementById("MyIframe").style.display = "none";
  9.    
  10. }
  11.  
  12. </script>
  13.  
  14. <a href='#' onclick='CloseIframe();'>Close Iframe</a>
  15.  
Heal your mind, and the body will follow
  • joebert
  • Packaging Tape
  • Genius
  • User avatar
  • Joined: 10 Feb 2004
  • Posts: 8658
  • Loc: Clearwater, FL
  • Status: Online

Post May 12th, 2008, 2:03 am

Does it happen if the <iframe> link code uses return false ?

  1. <a href='#' onclick='CloseIframe();return false;'>Close Iframe</a>


Maybe some sort of timing issue where that link causes a refresh before the other script actually completes running is what I'm thinking.
Error: 0xC0FFEE is empty

Post May 12th, 2008, 2:10 am

joebert, you have done it again.

I owe you good knows how many pints now.

Think you can drink heavy for a week on me now.

Thanks mate.
Heal your mind, and the body will follow

Post Information

  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2008. Driven by phpBB © 2001-2008 phpBB Group.

 
 
 
 

Need a pre-made web design for your website?

Check out our templates here: Ozzu Templates


400+ FREE Website Templates. Download Now!