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 许可协议。转载请注明出处!
相关文章
返璞归真!使用 Alpine.js 开发交互式 web 应用,抛弃 node_modules 和 webpack 吧!
前端框架层出不穷,项目越做越大,alpine.js 和 htmx 这种库是反其道而行,可以用最简单的方法来开发现代化的 web 应用。
2024-11-21 · Web前端 · 约 1 分钟
使用国内NPM镜像源提高速度
NPM介绍 npm(全称 Node Package Manager,即“node包管理器”)是Node.js默认的、以JavaScript编写的软件包管理系统。 npm可以管理本地项目的所需模块并自动维护依赖情况,也可以管理全局安装的JavaScript工具。 但是由于npm的源在国外,所以国内使用起来动辄10kb/s,甚至根本下载不了,所以使用国内镜像源替代官方源就很有必要了。 国内源 淘宝np
2022-02-25 · Web前端 · 约 1 分钟
在Next.js中集成swagger文档
Next.js 本来就不能直接用 Swagger,非要用还得自己折腾 API Routes?自动生成工具?手动写 Spec?这简直是在侮辱开发者。手动注释?这操作简直是在挑战耐心极限。
2025-09-01 · Web前端 · 约 1 分钟
使用 swagger-typescript-api 在前端项目里生成请求代码
swagger-typescript-api?文档写得像草稿,还得自己摸索。那些花哨的模块化选项除了报错还能干嘛?老老实实生成单文件,配个客户端封装,省得每次折腾。
2025-11-03 · Web前端 · 约 1 分钟
讨论
共 0 条加载评论中…