I have two page index.html and my.html
the my.html will appear as iframe in index.html
and in my.html will a link, if any one click the link http://www.swisteronline.in need to open. I do it, but the page http://www.swisteronline.in is opening in iframe in place of my.hml. but i need to open the site in place of index.html what to do?
index.html
<html>
<head>
<title>Index</title>
</head>
<body>
<iframe src="my.html" height="100%" width="100%" scrolling="no" frameborder="0">`</iframe>`
</body>
</html>
my.html
<html>
<body>
Click here to go
</body>
I need to open http://www.swisteronline.in when anyone clicke on "Click here to go" in place of index.html. I can only open it in place of my.html
what to do? please help... thanks
Add target="_parent" in anchor tag inside my.html
Click here to go
Related
When the tag is clicked, I want it to open another .html file (for example could be called discussions.html) in another tab.
<!DOCTYPE html>
<html>
<head>
<body>
open new html file
</body>
</head>
</html>
You just have to set the target of the link to blank, that's all.
See below:
<html>
<head>
<body>
DISCUSSIONS
</body>
</head>
</html>
If you want to open link in a new tab:
some text
Or for page in your domain:
some text
You would want to put a link inside there ^^
e.g. /dist/discussion.html" if you want to make it point on another one of your websites
in this project
or http://google.com if you want it to redirect to another existing site
In the following code the src attribute of iframe always shows b.html in devtools insepct, even after clicking on the link in the b.html page
index.html
<html>
<body>
<iframe src="b.html">
</iframe>
</body>
</html>
b.html
<html>
<body>
link
</body>
</html>
d.html
<html>
</html>
The spec doesn't appear to explain why this is the case, other than by stating that the WindowProxy operates independently of the element itself (for what it's worth). It does confirm that this is expected behavior (W3C HTML5, WHATWG HTML):
If the user navigates away from this page, the iframe’s corresponding WindowProxy object will proxy new Window objects for new Document objects, but the src attribute will not change.
As #BoltClock said, the src= attribute of the iframe doesn't change but you can get the new url of the iframe by accessing its
document.getElementById('my-iframe').contentWindow.location.href
but your iframe has to be on the same domain as the page hosting it.
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.
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>
Link
</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.
Try adding the target attribute as shown below
Link
the tag _parent will target the iframe's immediate parent window.
the tag _top will target the top window.
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>
This drives me totally crazy now. A link (http://ns.nl) on the page inside the iframe I made wont work (http://newsoundsofeurope.com/videos/playlisttest). Chrome doesn't do anything after the mouse click. Firefox just opens a blank page inside the iframe. Anyone can help?
Page with iframe:
<html>
<head>
</head>
<body>
<iframe src="playlist_iframe.php"></iframe>
</body>
</html>
Page inside iframe:
<html>
<head>
</head>
<body>
<img src="026.png"/>
</body>
</html>
Remove target="_self and will work.
If you want to open that link with a new page, you need to set the target="_blank"
<img src="026.png"/>
Also need to set the 'allow-popups' permission in the iframe
<iframe src="playlist_iframe.php" sandbox="allow-popups"></iframe>
https://www.w3schools.com/tags/att_iframe_sandbox.asp
When I click the link home on the page, the corresponding file opens up in the iframe shown by the arrow as it is targeted at it.
But, when I right click the link and click on open link in new tab then only the page corresponding to the link i.e the content of the iframe, opens up in the new tab and not whole layout.
What I want is that when I open that link in a new tab, the exactly same thing opens up in the new tab as shown in figure.
So basicly your problem is: you need to check if the iframe content is actually being open inside an iframe.
With window.top you can achieve that.
After that, if you content is not being open inside an iframe, make it redirect to the main page.
This is a sample, but i guess you can adapt for what you want:
home.html
<html>
<head>
<title>Main Page</title>
<head>
<body>
<h1>Main Page</h1>
Page 2
<iframe name="myIframe" src="page1.html"></iframe>
</body>
</html>
and page2.html
<html>
<head>
<title>Page 2</title>
<script>
if (window.top == window.self) {
window.location.replace("mainpage.html");
}
</script>
<head>
<body>
<h1>Page 2</h1>
</body>
</html>