以前我总是企图拿iframe套个网站,然后想通过js来对这个网站做一点操作。但是并没有做过实验,经测是不可能的。
<html>
<body>
<iframe src=’http://www.baidu.com’ width=800 id=’11’>
</iframe>
<button onclick=’javascript:document.getElementById(“11”).src=”javascript:alert(1)”‘>test
</button>
</body>
</html>
这个是无效的,src正常情况是可以改的,但改成js就无效了。
另外,location=’javascript:alert(1)’这种语句在控制台里是可以运行的,但貌似不可以在chrome扩展里用(以前测试的结果)