启用/禁用JavaScript代码 [英] Enable / Disable JavaScript code
问题描述
我在我的网站上,有一些JavaScript代码负责滚动网站。
我想创建触发按钮,以便用户可以启用/禁用
< script src =/ plugins / js / somejs1.js>< / script>
< script src =/ plugins / js / somejs2.js>< / script>
< script type =text / javascript>
//一些js(我想要的代码是一个触发按钮)
< / script>
< span type =checkboxid =the1checked>
显示/隐藏按钮
< / span>
< div id =trigger1>
文本文本文本
< / div>
可以用PHP完成吗?
第一部分:
纯粹用javascript完成:
尝试保存带有true / false值的cookie以保持scrollingEnabled值,然后使用常规按钮将其从true更改为false,反之亦然
用php来做:打印一个带有属性或者内部文本'true'/'false'的元素或者设置一个cookie。
第二部分
在该滚动功能中,首先检查cookie或自定义元素并根据您的值执行函数的代码。 b $ b
I have in my website, some javascript code that is responsible for the scrolling in the site.
I want to create trigger button so the users can enable/disable it.
<script src="/plugins/js/somejs1.js"></script>
<script src="/plugins/js/somejs2.js"></script>
<script type="text/javascript">
// some js (the code i want make a trigger button)
</script>
<span type="checkbox" id="the1" checked>
Display/Hide Button
</span>
<div id="trigger1">
Text Text Text
</div>
Can it be done with PHP ?
part one:
to do it purely with javascript:
try saving a cookie with a true/false value to keep the scrollingEnabled value, and then using a regular button change it from true to false and vice versa accordingly
to do it with php: print an element with an attribute or inner text 'true' / 'false' or set a cookie.
part two
in that scrolling function first check the cookie or your custom element and execute the function's code according to the value u have.
这篇关于启用/禁用JavaScript代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!