How to redirect user using location.search inside widget's client script

Alon Grod
Tera Expert

How can I redirect the user to specific url that I want using location.search?
for example if the condition is met and I want to redirect the user to www.google.com or to a different url, how can I do that?

WhatsApp Image 2023-11-27 at 13.16.16.jpeg

4 REPLIES 4

Maik Skoddow
Tera Patron

Hi @Alon Grod 

 

If you want to simulate someone clicking on a link, use location.href

top.location.search = "http://www.google.com";

 

If you want to simulate an HTTP redirect, use

top. location.replace = "http://www.google.com";

 

Maik

@Maik Skoddow hi Maik, I just want to redirect the user straight to a desired page. I tried to use:

location.url(link);

The user is being redirect to the desired page but the problem is I can see two pages in one page (SOW inside SOW), but i think its because Im using location.url instead of location.search:

WhatsApp Image 2023-11-27 at 15.13.14.jpeg


This is the full script:

WhatsApp Image 2023-11-27 at 15.06.04.jpeg




Hi @Alon Grod 

did you read my answer carefully?

 

I wrote

top.location.search

 

There is a reason for the leading "top." !!!

 

Maik

@Maik Skoddow but why did u use '=' instead of ()