在父窗口中打开iframe中的链接

时间:2017-02-28 17:16:17

标签: javascript html iframe

我有以下html结构

我试图在父窗口中打开链接。现在链接在iframe中。我尝试添加target =" _parent"链接但不起作用。奇怪的是,一些链接有效,但登录链接不起作用。

<div class="mrvl-header-wrapper">
    <div class="mrvl-header-bg"></div>
    <header class="mrvl-header">
        <button class="glb-nav-hamburger fouc hide" data-auto="glb-nav-hamburger" tabindex="0"></button>
        <a href="/"><p class="mrvl-logo" data-auto="brand-logo">Adobe Spark</p></a>
        <div class="mrvl-mrkt-nav">
            <a href="/" class="mrvl-mrkt-nav-link mrvl-mrkt-nav-about" data-auto="mrvl-mrkt-nav-about">About</a>
            <a href="/" class="mrvl-mrkt-nav-link mrvl-mrkt-nav-projects" data-auto="mrvl-mrkt-nav-projects">My Projects</a>
            <a href="/gallery/" class="mrvl-mrkt-nav-link mrvl-mrkt-nav-gallery" data-auto="mrvl-mrkt-nav-gallery">Inspiration Gallery</a>
            <a href="/blog" class="mrvl-mrkt-nav-link mrvl-mrkt-nav-blog" data-auto="mrvl-mrkt-nav-blog">Blog</a>
            <div class="mrvl-mrkt-learn-more-drop">
                <a class="mrvl-mrkt-nav-link mrvl-mrkt-nav-learn-more" data-auto="mrvl-mrkt-nav-learn-more">Learn More</a>
                <ul class="mrvl-mrkt-nav-learn-more-features">
                    <li><a href="/features/" class="mrvl-mrkt-nav-link mrvl-mrkt-learn-more-link mrvl-mrkt-feature-link">Features</a></li>
                </ul>
            </div>
            <div class="mrvl-mrkt-make-a-design-drop">
                <a class="mrvl-mrkt-nav-link mrvl-mrkt-nav-make-a-design" data-auto="mrvl-mrkt-nav-make-a-design">Make a Design</a>
                <ul class="mrvl-mrkt-nav-make-a-design-features">
                    <li><a href="/make/album-cover-maker" class="mrvl-mrkt-nav-link mrvl-mrkt-make-a-design-link">Album Covers</a></li>
                    <li><a href="/make/invitation-maker/baby-showers" class="mrvl-mrkt-nav-link mrvl-mrkt-make-a-design-link">Baby Shower Invitations</a></li>
                </ul>
            </div>
        </div>
        <div class="nav-cta-actions">
            <a target="_parent" href="/login" data-context="marketingNav" class="mrvl-mrkt-nav-cta-btn signup-cta-btn mrvl-mrkt-nav-logged-out-cta mrvl-mrkt-nav-login" data-auto="mrvl-mrkt-nav-login">Log in</a>
            <a target="_parent" href="/login" data-context="marketingNav" class="mrvl-mrkt-nav-cta-btn mrvl-mrkt-nav-logged-out-cta signup-cta-btn mrvl-mrkt-nav-start-now" data-auto="mrvl-mrkt-nav-start-now">Start now for free</a>
            <a target="_parent" href="/#create" class="mrvl-mrkt-nav-cta-btn mrvl-mrkt-nav-logged-in-cta mrvl-mrkt-nav-create hide" data-auto="mrvl-mrkt-nav-create"></a>
        </div>
        <div class="site-nav">
            <a href="/#" class="site-nav-link site-nav-projects selected" data-auto="site-nav-projects">My Projects</a>
            <a href="/gallery/" class="site-nav-link site-nav-gallery" data-auto="site-nav-gallery">Inspiration Gallery</a>
            <a href="/blog" class="site-nav-link site-nav-blog" data-auto="site-nav-blog">Blog</a>
        </div>
        <div class="agn-wrap fouc">
            <div class="agn-container"></div>
        </div>
        <nav class="user_placard hide">
            <button class="signin-btn" data-auto="signin-btn">
                <span class="signin-btn-icon"></span>
                <span class="signin-btn-label"></span>
            </button>
            <div class="mrvl-user-menu hide"></div>
        </nav>
        <div class="active-authoring-context fouc hide"></div>
    </header>
</div>
<div class="mrvl-user-menu-screen mrvl-overlay-bg hide"></div>
<div class="glb-nav-menu"></div>

1 个答案:

答案 0 :(得分:0)

Difference between _self, _top, and _parent in the anchor tag target attribute

target="_top"这会在它嵌套的所有帧之外中断,并在浏览器窗口中打开链接作为顶层文档。

target="_parent"如果它们嵌套在一个框架中,将在下一级别打开它