简体   繁体   English

暂时禁用某个页面的 javascript 警报?

[英]Temporarily disabling javascript alerts from a certain page?

I'm making code edits to my website within cPanel's file manager.我正在 cPanel 的文件管理器中对我的网站进行代码编辑。 With the latest update of cPanel v.104, after saving my file, control+Z does not revert my changes.随着 cPanel v.104 的最新更新,在保存我的文件后,control+Z 不会恢复我的更改。

Now, A javascript alert pops up asking: "Are you sure you want to save? The file will be overwritten."现在,会弹出一个 javascript 警报,询问:“您确定要保存吗?该文件将被覆盖。”

I hypothesize that a redefinition of the alert function, locally via my javascript console could stop this behavior and thus reclaim my control+Z ability.我假设通过我的 javascript 控制台在本地重新定义警报功能可以阻止这种行为,从而恢复我的 control+Z 能力。

window.alert = function() {};

Well, this does successfully disable alerts when I throw it in the console.好吧,当我将它扔到控制台时,这确实成功地禁用了警报。 Is it incorrect methodology to paste this in the console?将其粘贴到控制台中是不正确的方法吗? Is there something else I should do?还有什么我应该做的吗?

Here is a thread tracking this issue: https://forums.cpanel.net/threads/cpanel-40934-website-com-says-are-you-sure-you-want-to-save-the-file-will-be-overwritten.701853/这是一个跟踪此问题的线程: https ://forums.cpanel.net/threads/cpanel-40934-website-com-says-are-you-sure-you-want-to-save-the-file-will- 被覆盖.701853/

Alert box is used to provide the user some information.警报框用于向用户提供一些信息。 When trying to receive approval or disapproval, confirm() is used.当尝试接收批准或不批准时,使用confirm()

Try pasting this code in your web dev tools console.尝试将此代码粘贴到您的 Web 开发工具控制台中。

window.confirm = function() {};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM