跨域修改iframe内的文字

所用到的js脚本:

<script type="text/javascript">
document.getElementsByTagName("iframe")[0].src="replace.php?"+document.getElementsByTagName("iframe")[0].src;
<
/script>

replace.php代码:

<?php
$site=$_SERVER['QUERY_STRING'];
$ch = curl_init();
          
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
          
curl_setopt($ch, CURLOPT_URL, $site);
          
$content  = curl_exec ($ch);
          
curl_close ($ch);
$content=str_replace("browser","崔凯到此一游",$content);
//将iframe对方页面的browser替换为崔凯到此一游
echo $content;
exit;

演示地址:http://uicss.cn/test/replace.html

崔凯博客
Powered by WordPress | Theme by ck web design | TOP 顶部
Copyright © 崔凯 All rights reserved. 蜀ICP备12025891号.