Disable Cookies Inside A Frame/Iframe

2020-03-17 04:56发布

Is there any way to programatically disable cookies being created by a page displayed inside of a frame/iframe? Or to generalise further, is it possible to programatically disable javascript running on such a page?

Thanks,

DLiKS

3条回答
Luminary・发光体
2楼-- · 2020-03-17 05:08

If you mean that you want to change the settings of the browser by code in a web page, then no, this is not possible (and if it were possible, it's a huge security breach and all alarms would go off).

You may surpass this, however, by writing a plugin, but then each user must first download the plugin. You can also request higher priviledges, but it'll depend on the browser whether you can change any user settings.

If you mean that you want to write a script on every pc in your company to disable JS + cookies for certain pages, you can write plugins and install them everywhere, or use a proxy (as has been suggested by others) and filter the pages. If it is just for debugging a self-made page, use the Developer Toolbar for the various browsers, that can turn JS/Cookies on and off.

Why would you want to do such a thing? If you want to disable cookies, you disable it on your own page by simply not using cookies. The same goes for javascript: don't add it to your page and you've disabled it on your page.

Note: if any page would change anything of the user settings of the browser, your page will probably be blacklisted by Google, most virus scanners and fishing prevention tools.

查看更多
Animai°情兽
3楼-- · 2020-03-17 05:23

The only way you could change that for an external website you have no control over is to retrieve the pages using a server-side script, filter the input and display it to the user (ie: act as a proxy).

You just can't modify sites out of your domain (or subdomain - it might depend on the browser) using J/S for security reasons.

查看更多
趁早两清
4楼-- · 2020-03-17 05:32

with iframe sandbox attribute (html5) it will be possible (implemented in chrome)

http://dev.w3.org/html5/spec/Overview.html#attr-iframe-sandbox

NullUserException already answered what you can do today without browser support

查看更多
登录 后发表回答