Created
March 5, 2020 11:03
-
-
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)
This file contains 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
<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