加载脚本并在链接触发时执行
我在所有页面上都有一个cookie横幅加载,我想防止脚本在隐私政策页面上加载。但是需要脚本来访问cookie设置。 加载cookie横幅和此脚本需要的主要脚本
<script src="lib/js/cookieconsent.js"></script>
启动了cookie横幅。
<script>
function f1() {
let loadCookie2 = document.createElement("script");
loadCookie2.type = "text/javascript";
loadCookie2.setAttribute("src", "lib/js/cookieconsent-init.js");
document.body.appendChild(loadCookie2);
}
</script>
触发设置的链接
&lt; a href =“ javascript:f1();” type =“ button” data-cc =“ c-settings”&gt; cookie设置&lt;/a&gt;
data-cc =“ c-settings”
加载cookie设置,以及当我单击链接首先加载脚本,然后单击后,它显示了设置。
如何防止我可以同时触发它们?
I have a cookie banner loading on all pages and I want to prevent the script from loading on the Privacy Policy page. But the script is needed to access the cookies settings.
Main scripts that needed to load the cookie banner
<script src="lib/js/cookieconsent.js"></script>
and this script initiate the cookie banner.
<script>
function f1() {
let loadCookie2 = document.createElement("script");
loadCookie2.type = "text/javascript";
loadCookie2.setAttribute("src", "lib/js/cookieconsent-init.js");
document.body.appendChild(loadCookie2);
}
</script>
the link that triggers the settings
<a href="javascript:f1();" type="button" data-cc="c-settings">cookie settings</a>
data-cc="c-settings"
loads the cookie settings, and when I click on the link it first loads the script and after a second click it shows the settings.
How to prevent that can I trigger them simultaneously?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在@cbroe评论的帮助下,这是解决方案
在配置文件中。 cookieConsent-init.js
uncomment
autorun
并添加With the help of @CBroe comment this is the solution
In the configuration file. cookieconsent-init.js
uncomment
autorun
and add