admin管理员组

文章数量:1289565

I know there are a lots of questions like this, but we're already knew that each cases are not like each other.

So, this is my case :

HTML OUTPUT: PAGE 1

<div id="login-embedded" style="height: 401px; display: none;">
<iframe frameborder="0" src="{$mybb->settings['bburl']}/login.php" style="height: 401px;"></iframe>
</div> <!-- /end login-embedded -->
<div id="blackout"></div>

HTML OUTPUT: IFRAME

<div id="embedded-login">
<h1>{$lang->login}</h1>
<form method="post" action="{$mybb->settings['bburl']}/member.php">
<a id="embedded-close" href="javascript:;" onclick="jQuery('#blackout, #login-embedded').hide('slow');" rel="closeLogin"></a>
<div>
......
</div>

JQUERY :

jQuery(document).ready(function(){
jQuery('a[name="login"]').click(function(){
    jQuery("#blackout").fadeIn(1000);
    jQuery("#blackout").fadeTo("slow",0.8);
    jQuery("#login-embedded").show();
    return false
});

jQuery("#embedded-login a#embedded-close").click(function(){
    jQuery("#blackout").hide("slow");jQuery("#login-embedded").hide("slow");
    return false
});

jQuery("#blackout").click(function(){
    jQuery(this).hide("slow");
    jQuery("#login-embedded").hide("slow");
    return false
})
});

Did I miss anything here ? I found a solution for closing an iframe by using jquery dialog but seem it can't work in my case.

Any help will be appreciated ! Thanks!

I know there are a lots of questions like this, but we're already knew that each cases are not like each other.

So, this is my case :

HTML OUTPUT: PAGE 1

<div id="login-embedded" style="height: 401px; display: none;">
<iframe frameborder="0" src="{$mybb->settings['bburl']}/login.php" style="height: 401px;"></iframe>
</div> <!-- /end login-embedded -->
<div id="blackout"></div>

HTML OUTPUT: IFRAME

<div id="embedded-login">
<h1>{$lang->login}</h1>
<form method="post" action="{$mybb->settings['bburl']}/member.php">
<a id="embedded-close" href="javascript:;" onclick="jQuery('#blackout, #login-embedded').hide('slow');" rel="closeLogin"></a>
<div>
......
</div>

JQUERY :

jQuery(document).ready(function(){
jQuery('a[name="login"]').click(function(){
    jQuery("#blackout").fadeIn(1000);
    jQuery("#blackout").fadeTo("slow",0.8);
    jQuery("#login-embedded").show();
    return false
});

jQuery("#embedded-login a#embedded-close").click(function(){
    jQuery("#blackout").hide("slow");jQuery("#login-embedded").hide("slow");
    return false
});

jQuery("#blackout").click(function(){
    jQuery(this).hide("slow");
    jQuery("#login-embedded").hide("slow");
    return false
})
});

Did I miss anything here ? I found a solution for closing an iframe by using jquery dialog but seem it can't work in my case.

Any help will be appreciated ! Thanks!

Share Improve this question asked May 16, 2013 at 6:36 LCTGLCTG 2501 gold badge3 silver badges14 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

Your onclick="jQuery('#blackout, #login-embedded').hide('slow');" in the iframe isn't going to do anything because those elements are on the parent page. Try this:

onclick="window.parent.jQuery('#blackout, #login-embedded').hide('slow');"

The window.parent.jQuery bit will use the parent document's instance of jQuery to run the animation.

本文标签: javascriptClose Iframe With JqueryStack Overflow