user3654401
user3654401

Reputation: 3

Add a parameter in the of my URL?

First of all, so everyone here can undestand, I have a script to get the parameter:

<script>
function getURLParameter(name) {
    return decodeURI(
        (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] || ''
    );
}
</script>

This script add the parameter:

<script>document.write(getURLParameter('code'))</script>

I need to implement the script above, here:

<script>
document.getElementById('destiny').innerHTML = Destination.linkHtml('https://myurl.php?code=PARAMETER');
</script>

Upvotes: 0

Views: 52

Answers (1)

userbd
userbd

Reputation: 179

If you just need to append the result of getURLParameter('code') to your query string, you could use:

<script>
var parameter = getURLParameter('code');
document.getElementById('destiny').innerHTML = Destination.linkHtml('https://myurl.php?code=' + parameter );
</script>

Upvotes: 1

Related Questions