<iframe id="embed" frameborder="no" name="abc" border="0" src="www.lingpic.com" style="width:100%; color:#000;" mozallowfullscreen webkitallowfullscreen allowfullscreen></iframe>
1、先获取iframe再加focus()函数
document.getElementById('embed').focus();
2、在iframe框架里面点击元素让iframe获取焦点
如果www.lingpic.com里面有个<div id="box"></div> 的元素 那我们点击box让iframe获取焦点。例:
document.getElementById('box').onclick = function(){
var aFrame = parent.frames; //获取frames 是个类似数组
aFrame[0].focus();
}
3、在iframe里获取iframe的src
document.getElementById('box').onclick = function(){
var aFrame = parent.frames; //获取frames 是个类似数组
var src = aFrame[0].location.href;
//打开新窗口
window.open (src, 'newwindow', 'height=700, width=1000, top=50,left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
}
打开新窗口 newwindow名称只有不同的时候才能打开多个新窗口
我的网站打字练习传送门