-2

I want to open iframe URL in new tab.

Currently, my code opens iframe URL on same windows.

<html>
<head>
<title>Demo</title>
</head>
<body>
<!-- Start your code here -->

<div style="border: 2px solid #FFFFFF; overflow: hidden; margin: 15px auto; max-width: 1058px;">
<iframe scrolling="no" src="http://www.lazada.com.my/unbeatable-deals/?spm=a2o4k.home.sku-feed-slider-with-banner_27936.31.lbj3BM&bid=my15da" style="border: 0px none; margin-left: 0px; height: 1186px; margin-top: -285px; margin-bottom: -105px; width: 100%;">
</iframe>
</div>

<!-- End your code here -->
</body>
</html>
  • The point of an iframe is to put the URL in a frame in the same window. Why are you using an iframe if you want it in a new window? – Quentin Aug 15 '17 at 09:35
  • how do you want to open it in a new tab? is this something happen by a button click? it should be the same as opening a new tab for a normal page but this time it will contain your iframe. may be you need to create the iframe dynamically on the new tab, your question is not clear enough for me. – Amr Elgarhy Aug 15 '17 at 09:40
  • I want to bring a particular portion of website B into web site A. That's why I use above iframe method! Do you have any other method to do this? – SM Abdullah Aug 15 '17 at 09:45
  • i guess you need to use a href link to open a new tab ! i suggest to create another page that contain only the iframe and a link or a photo in this page – Malek Zarkouna Aug 15 '17 at 09:45
  • Amr Elgarhy: just click any URL inside iframe must open from new tab – SM Abdullah Aug 15 '17 at 09:46
  • "I want to bring a particular portion of website B into web site A.". Then you should include –  Aug 15 '17 at 09:51

1 Answers1

0

I want to bring a particular portion of website B into web site A. That's why I use above iframe

click any URL inside iframe must open from new tab

The link target is determined by the link itself, so in order to get the effect you want, you need to change the link element on website B.

That means you need access to edit website B. You cannot change the content (and link targets are content) of arbitrary third party websites.

You can either edit it directly, or dynamically change the links with JavaScript.

Since it is a different website, website A cannot directly access the link elements to change them. You would need to edit website B to include the JavaScript which modifies them (e.g. looping over document.links and setting the target on each). This could be triggered by postMessage and friends.

If you cannot edit website B then this is impossible.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335