Skip to content

Instantly share code, notes, and snippets.

@jacopo-nosto
Created March 5, 2020 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacopo-nosto/57833073fe101ab3d0e2213813311fe1 to your computer and use it in GitHub Desktop.
Save jacopo-nosto/57833073fe101ab3d0e2213813311fe1 to your computer and use it in GitHub Desktop.
Hiding/Displaying a Nosto element based on strings in the address (vanilla JS)
<div class="nosto_element" id="frontpage-nosto-1"></div>
<script type="text/javascript">
var myElement = _targetWindow.document.querySelector("#frontpage-nosto-1 .nosto_element");
_targetWindow.document.onreadystatechange = function () {
if (_targetWindow.document.readyState === "complete") {
var checkURL = ['collections/cluster-chandelier-lights',
'collections/table-lamps',
'collections/vintage-retro-industrial-metal-bar-stools'];
for (var i = 0; i < checkURL.length; i++) {
if(_targetWindow.window.location.href.indexOf(checkURL[i]) > -1) {
myElement.style.display = "none";
}
}
}
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment