Guest Gibran2 Posted December 2, 2019 Share Posted December 2, 2019 Hello, I'm new to squarespace. I'm trying to use the code block feature to run some very simple Javascript, but I'm not able to. The script is like this: <script> alert('hello'); </script> This is supposed to display a popup with 'hello' in it. But it doesn't. Reading the article on code blocks: https://support.squarespace.com/hc/en-us/articles/206543167-Code-Blocks ...tells me that Javascript in code blocks is a premium feature only. This *might* explain why it's not working for me, but I'm also wondering if I'm misunderstanding the point of code blocks. The article describes the point of code blocks as "rendering code". So I'm wondering if it is only meant to display code on the screen, NOT for running code. (This would explain why my Javascript is always displayed on the screen and I don't have the option to hide it). Thanks. Link to comment
paul2009 Posted December 2, 2019 Share Posted December 2, 2019 The code will run if HTML is selected as the format, and ‘Display Source’ is not checked. If the site is live, JavaScript will not run on personal plans. You may need to view the site whilst logged out to see the code working. About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥. Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links. Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional. Link to comment
brandon Posted December 3, 2019 Share Posted December 3, 2019 In addition to what Paul mentioned, you may also want to disable AJAX loading if your template supports it and has it enabled. The innerHTML() method by which body content is dynamically updated may cause scripts to misbehave (or rather, not behave at all). If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' (top-left) Link to comment
Guest Gibran2 Posted December 4, 2019 Share Posted December 4, 2019 Thanks both. I'm currently on a personal plan, so that's probably why the script isn't running. Even logging out and visiting my site won't run the script. I don't think I'm on a template. When I follow the instructions at this link: https://support.squarespace.com/hc/en-us/articles/115005308187 I see no template. It just says: Squarespace Version 7.1 And furthermore, I'm not seeing a "site styles" in the design menu as this link suggests there should be: https://support.squarespace.com/hc/en-us/articles/115000253288-Ajax-loading ...and I'm guessing this is because I'm not on a template. Link to comment
paul2009 Posted December 4, 2019 Share Posted December 4, 2019 41 minutes ago, Gibran2 said: I'm currently on a personal plan, so that's probably why the script isn't running That's exactly right. About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥. Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links. Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.