Jake235 Posted September 20, 2022 Share Posted September 20, 2022 <script> let imgs = document.querySelectorAll('section.page-section.gallery-section.full-bleed-section.background-width--full-bleed.section-height--medium.content-width--wide.horizontal-alignment--center img'); for (i= 0; i < imgs.length; i++) { alert("Hi!"); i++; } </script> <style>/* section.page-section.gallery-section.full-bleed-section.background-width--full-bleed.section-height--medium.content-width--wide.horizontal-alignment--center img { display: none !important;*/</style> This is the code that I am working with. I am trying to have it match to www.chicagofashioncoalition.org. I am able to get the images to disappear with the CSS that I have commented out, yet, Squarespace seems to edit out the javascript with the nodelist. Anyone have any ideas why Squarespace is not liking this particular line of JavaScript text? I've seen people able to manipulate, so, I know that it's possible. Link to comment
Beyondspace Posted September 20, 2022 Share Posted September 20, 2022 8 hours ago, Jake235 said: <script> let imgs = document.querySelectorAll('section.page-section.gallery-section.full-bleed-section.background-width--full-bleed.section-height--medium.content-width--wide.horizontal-alignment--center img'); for (i= 0; i < imgs.length; i++) { alert("Hi!"); i++; } </script> <style>/* section.page-section.gallery-section.full-bleed-section.background-width--full-bleed.section-height--medium.content-width--wide.horizontal-alignment--center img { display: none !important;*/</style> This is the code that I am working with. I am trying to have it match to www.chicagofashioncoalition.org. I am able to get the images to disappear with the CSS that I have commented out, yet, Squarespace seems to edit out the javascript with the nodelist. Anyone have any ideas why Squarespace is not liking this particular line of JavaScript text? I've seen people able to manipulate, so, I know that it's possible. I think you can apply the following event to make sure that all elements (including image) on your page is completely loaded <script> (function () { window.addEventListener('DOMContentLoaded', () => { // run your code here }); })() </script> BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox, video lightbox and much more) 🗓️ Delivery Date Picker (Squarespace Date picker form field) 💫 Gallery block 7.1 workaround 🥳 No-code customisations for Squarespace (+100 Spark plugin customisations) 🥳 Freemium Squarespace Widget Templates (+1000 Elfsight Templates) If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you! Link to comment
Jake235 Posted September 20, 2022 Author Share Posted September 20, 2022 7 hours ago, bangank36 said: I think you can apply the following event to make sure that all elements (including image) on your page is completely loaded <script> (function () { window.addEventListener('DOMContentLoaded', () => { // run your code here }); })() </script> Thanks. For some reason, that worked. I don’t know why Squarespace doesn’t work the way that you would expect it too. Beyondspace 1 Link to comment
Beyondspace Posted September 21, 2022 Share Posted September 21, 2022 (edited) May be your code runs at the time your images have not been loaded yet. Therefore, it can not work Edited September 21, 2022 by bangank36 BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox, video lightbox and much more) 🗓️ Delivery Date Picker (Squarespace Date picker form field) 💫 Gallery block 7.1 workaround 🥳 No-code customisations for Squarespace (+100 Spark plugin customisations) 🥳 Freemium Squarespace Widget Templates (+1000 Elfsight Templates) If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment