JamesJ Posted May 18, 2022 Share Posted May 18, 2022 (edited) I am trying to get a simple javascript array to pass to a squarespace page, but everything I have tried has not worked. Here is the latest code I attempted. I put the script in the Advanced code section for the page, and the HTML in a code section on the page. I can't get anything to display. I am using squarespace 7.1. Any help would be greatly appreciated. Thanks! in advanced code section... <script> var array = ['apple','ball']; document.getElementById('content').innerHTML = array.toString(); </script> in code section on page <div id="content"></div> Edited May 18, 2022 by JamesJ Link to comment
tuanphan Posted May 20, 2022 Share Posted May 20, 2022 Can you share link to your site? We can check easier Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
JamesJ Posted May 20, 2022 Author Share Posted May 20, 2022 Hi tuanphan, Thanks for offering to take a look at the site. This is the page - https://www.waileage.org/test. The code block is above the text on the page, but nothing is displayed. Kind regards, James Link to comment
tuanphan Posted May 21, 2022 Share Posted May 21, 2022 Try add a Code Block under current Code Block > Then paste script code (script you added in Advanced Code Section creedon 1 Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
creedon Posted May 21, 2022 Share Posted May 21, 2022 @tuanphan is right. What was/is happening is that the code in Page Settings > Advanced > Page Header Code Injection for the page is running before the code block in the page. So the code in the page header can not find the element because it doesn't exist yet. It is an order issue. Find my contributions useful? Please like, upvote, mark my answer as best , and see my profile. Thanks for your support! Link to comment
JamesJ Posted May 21, 2022 Author Share Posted May 21, 2022 Thanks tuanphan and creedon! Worked perfectly. creedon 1 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