Home  >  Q&A  >  body text

In PHP, iframe refers to an external web page. The hyperlink of the external web page has _blank. How to click the hyperlink to prevent it from jumping out of the iframe?

Webpage a

<iframe src="">https://b. The hyperlink in com/"></iframe>

b.com has the "target="_blank" attribute. Clicking the hyperlink directly opens a new window. How to make it After clicking the hyperlink, it is still displayed within the iframe?

I tried

<?php
$url="https://b.com"

$html= file_get_contents($url);

$str = str_replace("_blank","_self",$html);

echo '<iframe srcdoc=" '.$str.'"></iframe>'
?>

The iframe output like this is a whiteboard, echo $str directly, see I can't use it directly. Is there any way to solve this problem? I have searched in many places but can't find a solution. By the way, b.com is not mine, so I can't change the name

白菜券大**白菜券大**1712 days ago877

reply all(0)I'll reply

No reply
  • Cancelreply