chrome跨域访问iframe的元素
原创 2016年10月11日 22:29:04
设置chrome的打开参数 --args --disable-web-security --user-data-dir
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>测试</title>
</head>
<body>
搜索词:<input type="text" id="key" placeholder="input key" value="JS脚本">
点击第几条:<input type="text" id="start" placeholder="start num" value="5">
<button id="run">Run</button>
<br><br>
<iframe src="www.baidu" id="web_content" width="1024" height="768"></iframe>
<script>
var $ = {
keyObject:null,
startObject:null,
iframeObject:null,
buttonObject:null,
init:function(key,num,iframe,button){
this.keyObject = this.objById(key);
this.startObject = this.objById(num);
this.iframeObject = this.objById(iframe);
this.buttonObject = this.objById(button);
this.buttonObject.iframe参数传递onclick = this.searchKey;
},
searchKey:function(){
$.iframeObjById('kw').value = $.keyObject.value;
$.iframeObjById('su').click();
$.subClick();
},
subClick:function(){
setTimeout(function(){

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。