Solved

open and close iframe with javascript

Posted on 2010-09-08
3
686 Views
Last Modified: 2012-05-10
Hello, I am opening and closing an Iframe using javascript. The script works fine, unless I close the iframe, then try to open it again. It does not open the 2nd time. How can I get it to open again without refreshing the page?

Thank you.
Parent Page:



<script type="text/javascript">

    function TermsConditions()



    {

        document.all.Terms_Conditions_iframe.src = "Terms_Conditions.aspx";

        document.all.Terms_Conditions_iframe.style.visibility = "visible";

    }

</script>



<asp:HyperLink ID="Terms" runat="server" navigateurl="javascript:TermsConditions();" Font-Size="Small">Terms &amp; Conditions</asp:HyperLink>



<iframe  id="Terms_Conditions_iframe"  frameborder="0"  vspace="0"  hspace="0"  marginwidth="0"  marginheight="0"

                  width="700px"  scrolling="yes"  height="400px"  style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; Z-INDEX: 999; LEFT: 20px; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid; POSITION: absolute; TOP: 20px; visibility:hidden;">

            </iframe>





Child Page:



<a href="javascript: window.parent.document.getElementById('Terms_Conditions_iframe').style.display='none'">Close Window</a>

 Terms and conditions

Open in new window

0
Comment
Question by:mlg101
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 400 total points
ID: 33631904
Use :
.style.display='none'; // hide
and
.style.display='block'; // show

OR

.style.visibility='visible'; // hide
and
.style.visibility='hidden'; // show

not a mix because it's not the same thing : http://protocolsofmatrix.blogspot.com/2007/12/difference-between-visibility-display.html
0
 
LVL 3

Assisted Solution

by:Marbleman
Marbleman earned 100 total points
ID: 33632097
diplay="none" and display="block" ist probably what your are looking for, because visibilty="hidden" lets an element disappear but it still "comsumes" the space at it's location...
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33632366
Thanks for the points!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CSS Scroll Issue 3 87
jQuery not working on ELSE... why? 2 22
using php variable inside javascript 5 13
insert text field data into html script 13 25
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now