简体   繁体   中英

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?

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. An example of accessing foo.com/secure/page26 when not logged in results in being directed to 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:

** 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?

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

"But this doesn't work, I guess it is due to Rocketloader, but how can I get around this?"

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). You could also pause CloudFlare entirely in your settings to see if the behavior changes).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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