document.domain 跨域实现
2016-05-26 14:03
561 查看
<!DOCTYPE html> <html> <head> <meta charset='utf-8'/> <title>document.domains</title> </head> <body> <p>我是www页面</p> <iframe src="http://test.mzk.com/domains.html" id='ifm'></iframe> </body> <script type="text/javascript"> document.domain='mzk.com'; function alt(){ } var ifm=document.getElementById('ifm'); ifm.onload = function(){ var doc = ifm.contentDocument || ifm.contentWindow.document; // 在这里操纵b.html doc.getElementById('btn').onclick=function(){ alert('我是www页面'); } }; </script> </html>
上面是http://www.mzk.com/damains.html;
http://test.mzk.com/domains.html页面是:
<!DOCTYPE html> <html> <head> <meta charset='utf-8'/> <title>document.domains</title> </head> <body> <input type="button" class="btn" id="btn" value="按钮" > </body> <script type="text/javascript"> document.domain='mzk.com'; </script> </html>
相关文章推荐
- [书目20160526]Brain Rules 让大脑自由:释放天赋的12条定律
- gmail smtp 535 5.7.8无法登陆解决
- 13周练 D - Beautiful Paintings 【升数列】
- 游戏AI--决策(1)
- 机器人与人类“同床共枕“科技能让人类提升安全感?
- Sorting Railway Cars
- [leetcode] 172. Factorial Trailing Zeroes 解题报告
- 219. Contains Duplicate II
- Training Set, Validation Set 和Testing Set之间的差别及关系
- linux 系统监控、诊断工具之 IO wait
- on io scheduling again
- Codeforces Round #353 (Div. 2) B.Restoring Painting
- 服务器磁盘raid0,raid1,raid10,raid5,raid50,raid6,raid60 分析与案例
- 发展人工智能的中国特色
- FAQ系列 | 解读EXPLAIN执行计划中的key_len
- 规划(AI Planning)
- 采访 Gaijin Entertainment游戏Crossout,先睹为快吧
- codeforces 675-E Trains and Statistic 线段树+dp
- hdu 2686/hdu 3376 Matrix Again 费用流模板
- E-Mail相关函数