Jean-Luc Nacif Coelho
Jean-Luc Nacif Coelho

Reputation: 1022

Links in embedded html

I have some HTML code I'm trying to embed into a site. The code is an iframe that is supposed to have a bunch of links in it, but when I click the links, they just load the page inside the iframe block.

before click after click

Here is the code:

base.html

<head height="200" width="300">
    Text
</head>
<div>
<body>
    <iframe height="200" width="300" src="test.html"></iframe>
</body>
</div>

test.html

<head>
    <a href="file:///Users/Jean/base.html">Link</a>
</head>

Is there a way for me to tell the link NOT to load inside the frame?

I already know of a workaround which is to add "target="_blank"" to the link so it opens in a new tab.

Upvotes: 1

Views: 92

Answers (2)

Venkata Dorisala
Venkata Dorisala

Reputation: 5075

Try adding the target attribute as shown below

<a href="file:///Users/Jean/base.html" target="_parent">Link</a>

the tag _parent will target the iframe's immediate parent window. the tag _top will target the top window.

Upvotes: 2

rjustin
rjustin

Reputation: 1439

Try adding target="_top" this should target the parent URL instead of the iframe URL

<head>
    <a target="_top" href="file:///Users/Jean/base.html">Link</a>
</head>

Upvotes: 1

Related Questions