Configure Chrome to Support Cross-Origin Frames in Web Pages
Preface Cross-origin restrictions can ensure security, but turning them off is more convenient when debugging. However, the methods for disabling cross-origin restrictions that can be found online nowadays simply don't work on newer versions of Chrome... After some exploration, I found that using an older version of Chrome can bypass the cross-origin restrictions. The page I made that needs a cross-origin embedded frame is just for display, so this happens to fit my needs. Let's go! Then I found an old version of Chrome. After extracting it, it was a portable version that could run directly, but after running it I found it just launched the system's Chrome
目录5 个章节
Preface
Cross-origin restrictions can ensure security, but turning them off is more convenient when debugging. However, the methods for disabling cross-origin restrictions that can be found online nowadays simply don't work on newer versions of Chrome...
After some exploration, I found that using an older version of Chrome can bypass the cross-origin restrictions. The page I made that needs a cross-origin embedded frame is just for display, so this happens to fit my needs. Let's go!
Then I found an old version of Chrome. After extracting it, it was a portable version that could run directly, but after launching it I found it just started the system's Chrome, so I had to run it inside the Windows 10 sandbox (I have to say this sandbox is really convenient)
To disable Chrome's cross-origin restrictions, add the command-line argument --disable-web-security to Chrome's shortcut, as shown in the figure:

After running it, a prompt will pop up saying that an unsupported command-line argument was used and that it will reduce security, etc., which means it succeeded. At this point, visiting pages with cross-origin frames will work.
Using JS to Manipulate Elements Inside a Frame
This part is extra content, I'll briefly mention it... You can find it all with a search online
First you need to determine when the page inside the frame or iframe has finished loading. I was too lazy to check for that, so I made a button and judged it myself: wait until the page in the frame has loaded, then click this button, and it will automatically fill in the username and password on the page inside the frame and log in automatically
document.querySelector('#btn-login').onclick = function () {
var iframe_window = document.getElementById('hik').contentWindow
var iframe = iframe_window.document
}
Then you can use iframe.querySelector to freely manipulate the DOM inside the frame
Download Old Versions of Chrome
Chrome 45 version: https://pan.baidu.com/s/1bCv9W8gcm9oi0tHOKuAgGw (extraction code: 74xr)
For more versions, see this: https://www.zhihu.com/question/20364836
References
- Chrome 80's default SameSite causing cookies to be lost on cross-origin requests: http://www.withcoder.com/articles/server_side/zs/434.html
- iframe cross-origin, is there a way to get elements of the iframe child page: https://segmentfault.com/q/1010000017568917/a-1020000017570521
Feel Free to Discuss
Programming Lab focuses on exploring popular new internet technologies and team agile development practices. Reply with linux, flutter, c#, netcore, android, kotlin, java, python, etc. in the backend of the WeChat official account 「程序设计实验室」 to get related technical articles and materials. If you have any questions, you can also leave a message in the official account backend~
_EOF_
Configure Chrome to Support Cross-Origin Frames in Web Pages
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
使用 swagger-typescript-api 在前端项目里生成请求代码
swagger-typescript-api?文档写得像草稿,还得自己摸索。那些花哨的模块化选项除了报错还能干嘛?老老实实生成单文件,配个客户端封装,省得每次折腾。
2025-11-03 · Web前端 · 约 1 分钟
在网页中使用Material-Design图标
什么是Material Design图标 MD大家都听过的吧,就是谷歌的Material Design设计,Material Design图标就是符合 MD设计语言的图标。 本文通过字体的方法在网页中显示Material Design图标。 What are material icons Material design system icons are simple, modern, friend
2021-12-18 · Web前端 · 约 1 分钟
使用mock.js开发假数据接口
参考资料 Mockjs使用 - https://juejin.cn/post/6953199521031520292 http://wll8.gitee.io/mockjs-examples Mokcjs 文档 Vitepress版 - http://mock.pe666.cn/
2022-12-06 · Web前端 · 约 1 分钟
Vue2.x项目整合ExceptionLess监控
前言 一直以来我们都是用Sentry做项目监控,不过前段时间我们的Sentry坏掉了~~(我搞坏的)~~ 但监控又是很有必要的,在sentry修好之前,我想先寻找一个临时的替代方案,同时发现网上关于ExceptionLess的资料少得可怜,ExceptionLess官方的文档也不是很完善,翻了好久文档和源码,于是有了本文…… 关于ExceptionLess 写.NetCore的同学应该不会陌生,这
2022-03-23 · Web前端 · 约 1 分钟
讨论
共 0 条加载评论中…