54
Views
10
Comments
Solved
Clear input parameters in url

Hi All

I have used the below javascript code to clear the input parameters shown in the url but when the page is refreshed since the input parameters are not there it is not behaving correctly. kindly let me know how to fix this issue

var uri = window.location.toString();if (uri.indexOf("?") > 0) {    var clean_uri = uri.substring(0, uri.indexOf("?"));    window.history.replaceState({}, document.title, clean_uri);}

Thanks

Kumar V

2019-11-11 17-10-24
Manish Jawla
 
MVP
Solution

Hi @saravanakumar v ,

I have created the below forge component that will help you understand this concept with example.

https://www.outsystems.com/forge/component-overview/20876/how-to-hide-url-parameters-o11

Regards,

Manish Jawla 

2023-03-08 10-32-19
Vinod Kumar R

Hi @saravanakumar v , Please try using the window.location.href = clean_uri; 

var uri = window.location.toString();

if (uri.indexOf("?") > 0) { 

var clean_uri = uri.substring(0, uri.indexOf("?"));

window.location.href = clean_uri;

Regards,

Vinod

UserImage.jpg
saravanakumar v

Hi Vinod

The code is not working

2020-08-31 05-04-40
Rahul Jain

Hi @saravanakumar v , 
Please try below code.

// Before removing the parameters, store them in sessionStorage

var uri = window.location.toString();

var urlParams = new URLSearchParams(window.location.search);

if (urlParams.toString()) {

    sessionStorage.setItem('urlParams', urlParams.toString());

}


// Clean the URL by removing the parameters

if (uri.indexOf("?") > 0) {

    var clean_uri = uri.substring(0, uri.indexOf("?"));

    window.history.replaceState({}, document.title, clean_uri);

}


// When the page is refreshed, check if the parameters were stored in sessionStorage

window.addEventListener('load', function() {

    var storedParams = sessionStorage.getItem('urlParams');

    if (storedParams) {

        // Reapply the stored parameters to the URL if needed

        window.history.replaceState({}, document.title, window.location.pathname + '?' + storedParams);

    }

});


Thanks

--RJ--

UserImage.jpg
saravanakumar v

Hi Rahul

I have the previous code in onready action. can i place all this code in the same action ? please advise

Thanks

Kumar V

2020-08-31 05-04-40
Rahul Jain

 Yes ,  you can use this code in onready event

UserImage.jpg
saravanakumar v

Hi Rahul

The code did not work. Any advise

Thanks

Kumar V

2019-11-11 17-10-24
Manish Jawla
 
MVP

Hi @saravanakumar v ,

It will good if you put your detail screen logic inside the web block where you are passing the inputs which are visible over the url and call it inside your list screen by using simple condition and Boolean variable.

That will fix your parameters shown in url :).

Regards,

Manish Jawla

UserImage.jpg
saravanakumar v

hi manish

could you please give a sample oml. i am not able to understand it

2019-11-11 17-10-24
Manish Jawla
 
MVP
Solution

Hi @saravanakumar v ,

I have created the below forge component that will help you understand this concept with example.

https://www.outsystems.com/forge/component-overview/20876/how-to-hide-url-parameters-o11

Regards,

Manish Jawla 

2025-04-22 05-54-18
Shashi Kant Shukla

Hi @saravanakumar v,

As per my understanding you are clearing the input parameter from URL due to security constraint, if yes there is another alternate option while you are creating records in entity you can save one more attribute UUID(unique id) along with entity identifier and you can pass it as a input parameter and in this way value of input can not be tempered.

Here is sample how you can save UUID in entity:

Regards

Shashi Kant Shukla

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.