Skip to content

Instantly share code, notes, and snippets.

@jacopo-nosto
Created Mar 5, 2020
Embed
What would you like to do?
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