如何在页面加载后暂时禁用javascript ?

时间:2022-10-06 22:52:38

I want to disable Javascript once a page has already loaded.

我想在页面已经加载之后禁用Javascript。

Why?

为什么?

Because I want to test how the behavior of something like the following 'degrades' when javascript isn't available, but i dont want the hastle of going to the browser's top level Javascript enable/disable feature. In addition I specifically want to disable it after the page has loaded because I want to isolate my testing to how that one form would perform (I have jQuery running for the rest of the page and I don't want to lose that).

因为我想测试当javascript不可用的时候,下面这些东西的行为是如何降低的,但是我不想去浏览器的*javascript启用/禁用特性。此外,我特别想在页面加载之后禁用它,因为我想将我的测试与表单的执行方式隔离(我让jQuery在页面的其余部分运行,我不想丢失它)。

Allowing me to disable JS for this code allows me to test the form postback as well as the AJAX postback.

允许我为这段代码禁用JS,允许我测试表单回发和AJAX回发。

<form action="/pseudovirtualdirectoryfortesting/company/Contact" id="fooForm" method="post" onsubmit="Sys.Mvc.AsyncForm.handleSubmit(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, loadingElementId: 'submitting', onBegin: Function.createDelegate(this, submitComments_begin), onComplete: Function.createDelegate(this, submitComments_complete), onFailure: Function.createDelegate(this, submitComments_failure), onSuccess: Function.createDelegate(this, submitComments_success) });">

<表单动作=" pseudovirtualdirectoryfortesting company contact" id="fooForm" method="post" onsubmit="Sys.Mvc.AsyncForm " handlesubmit(这个,新的sys.ui.domevent(event), {insertionmode: sys.mvc.insertionmode)。替换,装入符号:“提交”,onbegin:函数。submitcomments_begin createdelegate(这),oncomplete函数。onfailure submitcomments_complete createdelegate(这):功能。submitcomments_failure createdelegate(这),调用onsuccess:函数。createdelegate(这个,submitcomments_success)});">

What plug-ins or tactics could I use. I want to be able to test in different browsers, and some projects I work on are designed only for one browser (not my fault) so I need as many possible solutions as there are.

我可以使用什么插件或策略。我希望能够在不同的浏览器中进行测试,我所做的一些项目只针对一个浏览器(不是我的错),所以我需要尽可能多的解决方案。

3 个解决方案

#1


6  

Get the Web Developer Toolbar for Firefox. With it you can disable Javascript at any time, disable cookies, css, whatever you want.

获取Firefox的Web Developer工具栏。有了它,你可以随时禁用Javascript,禁用cookie, css,任何你想要的东西。

#2


2  

Test in FireFox with the NoScript addon.

在FireFox中使用NoScript addon进行测试。

#3


-1  

This is not answer to the generic question "how to disable javascript", but was a good solution for me.

这并不是“如何禁用javascript”这一一般性问题的答案,但对我来说是一个很好的解决方案。

I have stopped using Microsoft's AJAX in place of jQuery.

我已经停止使用微软的AJAX来代替jQuery。

As a result of this I am using unobtrusive javascript and it is therefore much easier to disable just the AJAX handler for my form than it is with Microsoft Ajax.

因此,我使用的是不引人注目的javascript,因此禁用表单的AJAX处理程序比使用Microsoft AJAX要容易得多。

All i do is comment out the line that hooks up the AJAX call to my submit button.

我所做的就是注释掉链接到我的submit按钮的AJAX调用的行。

#1


6  

Get the Web Developer Toolbar for Firefox. With it you can disable Javascript at any time, disable cookies, css, whatever you want.

获取Firefox的Web Developer工具栏。有了它,你可以随时禁用Javascript,禁用cookie, css,任何你想要的东西。

#2


2  

Test in FireFox with the NoScript addon.

在FireFox中使用NoScript addon进行测试。

#3


-1  

This is not answer to the generic question "how to disable javascript", but was a good solution for me.

这并不是“如何禁用javascript”这一一般性问题的答案,但对我来说是一个很好的解决方案。

I have stopped using Microsoft's AJAX in place of jQuery.

我已经停止使用微软的AJAX来代替jQuery。

As a result of this I am using unobtrusive javascript and it is therefore much easier to disable just the AJAX handler for my form than it is with Microsoft Ajax.

因此,我使用的是不引人注目的javascript,因此禁用表单的AJAX处理程序比使用Microsoft AJAX要容易得多。

All i do is comment out the line that hooks up the AJAX call to my submit button.

我所做的就是注释掉链接到我的submit按钮的AJAX调用的行。