Use case is as follows:
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @MayuriK
You can use custom code option in VEC. Add custom javascript to append query parameters in the URL. you can use following JS code.
function insertParam(key, value) {
key = encodeURIComponent(key);
value = encodeURIComponent(value);
// kvp looks like ['key1=value1', 'key2=value2', ...]
var kvp = document.location.search.substr(1).split('&');
let i=0;
for(; i<kvp.length; i++){
if (kvp[i].startsWith(key + '=')) {
let pair = kvp[i].split('=');
pair[1] = value;
kvp[i] = pair.join('=');
break;
}
}
if(i >= kvp.length){
kvp[kvp.length] = [key,value].join('=');
}
// can return this or...
let params = kvp.join('&');
// reload page with new params
document.location.search = params;
}
query.append("test","true");
let me know if this works.
Views
Replies
Total Likes
Hi @MayuriK
You can use custom code option in VEC. Add custom javascript to append query parameters in the URL. you can use following JS code.
function insertParam(key, value) {
key = encodeURIComponent(key);
value = encodeURIComponent(value);
// kvp looks like ['key1=value1', 'key2=value2', ...]
var kvp = document.location.search.substr(1).split('&');
let i=0;
for(; i<kvp.length; i++){
if (kvp[i].startsWith(key + '=')) {
let pair = kvp[i].split('=');
pair[1] = value;
kvp[i] = pair.join('=');
break;
}
}
if(i >= kvp.length){
kvp[kvp.length] = [key,value].join('=');
}
// can return this or...
let params = kvp.join('&');
// reload page with new params
document.location.search = params;
}
query.append("test","true");
let me know if this works.
Views
Replies
Total Likes
Thanks for the information. But here we are creating form based activity and trying to create an html offer to add parameter to the URL.
How can we do that in case of form based activity.
Current implementation is as follows:
HTML offer code:
setTimeout(()=>{
let videoAutoPlay = document.querySelector('video-js');
videoAutoPlay.player.muted(true);
videoAutoPlay.player.play();
},1000);
I am not sure if this is the correct way.
Views
Replies
Total Likes
If you are still searching for alternatives it would also be possible to accomplish this via a redirect:
ExpA: Default
ExpB: Redirect from url1.com --to--> url1.com/?playnowparameter
The only caveat is you have to test to validate you aren't setting up an infinite redirect loop. If the activity is configured to allow access only from url1.com it should work however if it's configured to allow access from url that contains url1 it will result in an infinite redirect loop. Hope this helps.
--Docea
This method cannot be used as there is not one url where we need auto play functionality. There are multiple page URL
Views
Replies
Total Likes
Oh okay. I believe using code which I shared should resolve your problems.
Views
Like
Replies
Views
Like
Replies