浏览器 js开窗口,代码注入问题解决
js开窗口方法:
参照:https://blog.csdn.net/qq_40660389/article/details/125312395
具体open参数:https://www.runoob.com/jsref/met-win-open.html
开小窗口+代码注入的方法:
//需要注意的是,打开的新窗口不能跨域!(再次用 根地址代替实验)
ref = window.open('/',"新标题?",'height=300,width=400,top=200,left=200,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
insertElement = ref.document.createElement("script");
insertElement.innerHTML="setInterval(()=>{console.log('xxxx')},1000)"
ref.document.body.appendChild(insertElement);
ref.close();
js文件另存为(给定name)
const link = document.createElement('a');
const body = document.querySelector('body');
link.href = "http://szpj.sdei.edu.cn/zhszpj/jcsj/bygl/byxsDacx.do?HHCSRFToken=7236a4ff-1e58-43cc-b97e-2e6e74398473&method=getZdaXsCk&xsJbxxId=MjAxMDM3MTMyMjEwMTExMDExMQ%3D%3D";
link.download = "xxx";
// fix Firefox
link.style.display = 'none';
body.appendChild(link);
link.click();
body.removeChild(link);
window.URL.revokeObjectURL(link.href);