dongyin5516 2015-04-13 14:28
浏览 954
已采纳

禁用当前页面的JavaScript

I'm building a debug script that is to be included at the top of my index.php

I would like to provide a checkbox that when checked, disables all javascript, jquery etc on the page.

I'm saving these settings with $_SESSION

I've already found a soloution that replaces all <script></script> tags with <!--<script></script>-->. But would like to know if there is anthing cleaner, more specific.

Since the file is included at the top of my index, could I write something in javascript to unbind any events/listeners/triggers etc?

I would prefer not to change any of my javascript, as the idea is to include this at the top of each project/build as a standalone piece. Thanks!

  • 写回答

1条回答 默认 最新

  • dpgf42422 2015-04-13 14:31
    关注

    You can't disable JavaScript with JavaScript.

    Simply put, you can't make sure your JS is the first to execute, nor can you reliably disable scripts all over the page.

    Imagine how that would mess with normal browsing... Some malicious site disables JS on your browser, and you're gonna have to figure out where the setting is.

    I'm sure that you can dream about resetting it, after an hour or 2 of browsing.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题