Streaming live at 10am (PST)

Custom script banned?


#1

Hello, I’m Christophe, UX designer, I write this topic cause I’m in trouble with a script in my custom code.
I explain,

I have two versions of my homepage (FR & EN) and I need to make URL redirections with browser language detection. So I write this script :


<script type= "text/javascript">

var language = window.navigator.language;

if(language == “fr”){
window.location.href = “name.webflow.io/fr/home”;
}

else if(language == “en-US” || language == “en-CA” || language == “en-AU”){
window.location.href = “name.webflow.io/en/home”;
}


I’d put it on the custom code textarea has usually and it work fine.
The problem was when I preview the page in Chrome, the script constantly reloads (and so send a lot of requests to the server…).
After investigating I find an issue, but before I had time to try it, I was suddenly logout of my Webflow account…
I’d login back few seconds after, when I was going to custom code section, the script was there without changes. But when I’m trying in my browser, it seems not working (but the script appear in the inspector).
I try different things but impossible to make it work again…

After reflexion, I think maybe Webflow have a kind of requests/ddos protection and banned my script (I don’t know how, unfortunately I’m not an expert in javascript).

Do you think it’s possible ? And if yes, how can I fix it ? Because it was 5 hours the problem appear and it’s not going back…

Thanks for your precious help,
Christophe


#2

Try removing the space after type=

… are you referring to the preview within the designer? The script tag shouldn’t load there, only when published. Could you share (or DM) your read-only link?


#3

Hello Forresto, thanks for your answer,

I try to remove the space but no changes…
I’m not referring to the designer preview, but to the real URL in a page of my browser.

This is the page : http://steerfox.webflow.io/

If you inspect you can see the script at the end of the body but it’s not working…
I find this kind of script on this topic : Language Detection and Redirect URL


#4

I see, your script is redirecting to http://steerfox.webflow.io/steerfox.webflow.io/en/home

You need to change your redirects to

var language = window.navigator.language;

if(language === "fr"){
  window.location.href = "https://steerfox.webflow.io/fr/home";
}
else if(language === "en-US" || language === "en-CA" || language === "en-AU"){
  window.location.href = "https://steerfox.webflow.io/en/home";
}

(add the https:// to both places)


#5

I made the change but not working.

But even if the script is redirecting to http://steerfox.webflow.io/steerfox.webflow.io/en/home, we must see a 404 error or broken link ? But it seem the script don’t work ?

Before I was logged out of my account, even if I put a wrong URL it sent me to a 404 page…
You don’t think Webflow can block the script ? Because before that, the page permanently refreshes cause of the script


#6

You have the redirect script also on https://steerfox.webflow.io/en/home … it should only be on https://steerfox.webflow.io/ … that’s why you have the infinite refresh issue.


#7

Thanks Forresto for your help, I find a solution, now the page don’t infinite refresh :