iframe with external page not working

后端 未结 3 1046
心在旅途
心在旅途 2020-11-27 22:13

I\'m tring to embed a webpage in an iframe, but it doesn\'t work at all. internal pages with relative path are displayed normally. but this simple code doesn\'t work:

<
3条回答
  •  借酒劲吻你
    2020-11-27 22:49

    Suppose your url is www.google.com, i.e $url = "www.google.com";

    $headerRes = get_headers($url);  //get the header response
    
    foreach($headerRes as $val)
      if($val=="X-Frame-Options: SAMEORIGIN" || $val=="X-Frame-Options: DENY"){
        header("location:".$url); 
        exit; 
      }
    //simply redirect to their website instead of showing blank frame
    

    I hope I explained myself good.

提交回复
热议问题