Forked from cgilchrist/replace_text_with_url_param.js
Last active
August 26, 2020 18:24
-
-
Save philbar/1dc88fcc0c89f3df55a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
var getUrlParams = function() { | |
var params = {}, hash; | |
var hashes = decodeURI(window.location.href).replace(/\+/g," ").slice(window.location.href.indexOf('?') + 1).split('&'); | |
for (var i=0; i<hashes.length; i++) { | |
hash = hashes[i].split('='); | |
params[hash[0]] = hash[1]; | |
} | |
return params; | |
}; | |
jQuery(function() { | |
// Add URL of image here. Make sure it is the same dimensions as the image you are replacing | |
var dynamicImage = "http://IMAGE-URL-GOES-HERE"; | |
// Update "keyword" to match the parameter you chose. | |
var keyword = getUrlParams()['keyword']; | |
// Update "Keyword to be matched". | |
if (keyword == "KEYWORD TO BE MATCHED") { | |
// Update "#lp-pom-image-01" to match the div of the image you want changed | |
jQuery('#lp-pom-image-01 img').attr('src', dynamicImage) | |
} | |
}); | |
</script> |
I am having the image problems.
This does not work. Any help. And also with multiple images? Thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello... I'm trying to implement this, but am not having any luck. I think I'm plugging the wrong information in to the wrong spot