我一直试图在index.php文件中的iframe上运行javascript代码,但没有成功,所以如果你们可以看看这个,我做错了什么,请:
下面是我的代码:
<script type="text/javascript">
window.onload = function() {
document.getElementById("resultFrame").contentWindow.iframe();
function iframe() {
var isCandidateRegion=function(node){
return (node.innerText.indexOf('Username')>-1 && node.innerText.indexOf('Hours')>-1);
};
//Find the last table in th document that contains 'Username' and 'Hours'
var candidateRegions=[].filter.call(document.querySelectorAll('table'),isCandidateRegion);
var targetRegion=candidateRegions[candidateRegions.length-1];
var isVisible=function(node){
return (node.offsetWidth && node.offSetWidth >0) || (node.offsetHeight && node.offsetHeight>0);
};
var inputs=[].filter.call(targetRegion.querySelectorAll('input'),isVisible);
inputs[0].value="nicefellow1234";
inputs[1].value="23";
inputs[2].click();
};
};
</script>
<iframe id="resultFrame" src="http://www.infamousgangsters.com/site.php?page=kill" height="700px" width="100%"></iframe>另外,我在控制台中遇到如下错误:
Error: Permission denied to access property 'iframe'所以如果你们能帮我的话..!
发布于 2015-01-03 04:52:06
我认为它被拒绝了,因为域名与iframe所在的域名不同。这是为了保护用户免受XSS攻击。
https://stackoverflow.com/questions/27748329
复制相似问题