简体   繁体   English

Cloudflare停止javascript将变量传递到外部文件

[英]Cloudflare stops javascript passing variables to external files

I have Rocketloader enabled in my cloudflare account so that might be the issue, but how can I work around it? 我在我的cloudflare帐户中启用了Rocketloader,这可能是问题所在,但是如何解决呢?

The situation is I have an external file login.js which handles login forms across the site, but when a user accesses a page when they aren't logged in, the requested url is appended to the login page. 情况是我有一个外部文件login.js ,该文件处理整个站点的登录表单,但是当用户未登录时访问页面时,所请求的URL会附加到登录页面上。 An example of accessing foo.com/secure/page26 when not logged in results in being directed to foo.com/login.php?back=secure/page26 . 在未登录时访问foo.com/secure/page26的示例导致定向到foo.com/login.php?back=secure/page26 so within my login page I have the following setup: 所以在我的登录页面中,我有以下设置:

<script>var BackURL="secure/page26";</script>
<script src="login.js"></script>

Within login.js I have: login.js我有:

** SUCCESFULLY LOGGED IN SCRIPT HERE **
window.location.href = "/"+BackURL;

But this doesn't work, I guess it is due to Rocketloader, but how can I get around this? 但这是行不通的,我想这是由于Rocketloader造成的,但是我该如何解决呢?

您可以将BackUrl参数存储在cookie中,并在每次登录时检查该cookie是否存在。如果已定义,则将其删除并将用户重定向到其值。

"But this doesn't work, I guess it is due to Rocketloader, but how can I get around this?" “但是这行不通,我想这是由于Rocketloader造成的,但是我该如何解决呢?”

The easy way to check this would be to simply disable Rocket Loader in your settings & then try it again (might need to flush your browser cache after doing it). 一种简单的检查方法是在设置中禁用Rocket Loader,然后再试一次(这样做后可能需要刷新浏览器缓存)。 You could also pause CloudFlare entirely in your settings to see if the behavior changes). 您还可以在设置中完全暂停CloudFlare,以查看行为是否发生了变化)。

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

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