Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

How to send data from a text component to a redirected page?

sanjayn66673968
Level 1
Level 1

i want to create a text component which will have a link which gets redirected to another page.How can i pass any text data into redirected page?

1 Accepted Solution
BrianKasingli
Correct answer by
Community Advisor
Community Advisor

@sanjayn66673968,

passing data from your redirect can be done via URL parameters; Take the example of [302 Redirect] URL: http://localhost:4502/content/my-site/ca/en-AK/home.html?dataID=211231332424424
The resulting page is expected to will have javascript reading the URL parameter "dataID"; this Javascript should be invoked from your client library. 

 

 

<script type="text/javascript">
function getUrlParameter(name) {
    name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
    var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
    var results = regex.exec(location.search);
    return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
alert(getUrlParameter('dataID');
</script>

 

 

The URL example provided above is for an Author environment, which is where you would probably be testing and developing your feature.

Hope this helps!

View solution in original post

1 Reply
BrianKasingli
Correct answer by
Community Advisor
Community Advisor

@sanjayn66673968,

passing data from your redirect can be done via URL parameters; Take the example of [302 Redirect] URL: http://localhost:4502/content/my-site/ca/en-AK/home.html?dataID=211231332424424
The resulting page is expected to will have javascript reading the URL parameter "dataID"; this Javascript should be invoked from your client library. 

 

 

<script type="text/javascript">
function getUrlParameter(name) {
    name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
    var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
    var results = regex.exec(location.search);
    return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
alert(getUrlParameter('dataID');
</script>

 

 

The URL example provided above is for an Author environment, which is where you would probably be testing and developing your feature.

Hope this helps!

View solution in original post