I am trying to add custom javascript to wix, but it doesnt work. I have tried almost all I found on google but it doesnt work.
<script type="text/javascript">
window.parent.location.href = "https://url/track"
</script>
The script above needs to be loaded on every wix page, it contains redirection
I was wondering if this is possible in wix?
I am trying to add custom javascript to wix, but it doesnt work. I have tried almost all I found on google but it doesnt work.
<script type="text/javascript">
window.parent.location.href = "https://url/track"
</script>
The script above needs to be loaded on every wix page, it contains redirection
I was wondering if this is possible in wix?
Share Improve this question edited Oct 29, 2019 at 1:40 Bob Arnson 21.9k2 gold badges42 silver badges50 bronze badges asked Oct 28, 2019 at 19:31 MarkoMarko 911 gold badge1 silver badge11 bronze badges3 Answers
Reset to default 3The way to add custom code to each page in a Wix site is by adding Site code in the built-in IDE.
To access it, enable Dev mode at the top menu and click the Site tab at the editor.
Note that you can't access the DOM directly. However, Wix has a pretty rich API that may cover your needs.
looks like you need to use the wix location API: https://www.wix./corvid/reference/wix-location.html#to
From my limited knowledge of wix it seems like your implementation is just wrong for the problem you're trying to solve.
I had a quick read of this article which isn't too old: https://www.wix./corvid/forum/munity-discussion/page-redirect and it seems like a better approach.
Make sure you've enabled DEV mode and then open the script panel at the bottom of the page. First, you should import the module that contains the method you need. In your case, that would be wixLocation. Inside the onReady function, you should call winLocation.to method.
import wixLocation from 'wix-location';
$w.onReady(function () {
wixLocation.to("http://some.new.location"))
});