Jump to content

Syntax error solved but I only get text on my website.

Recommended Posts

Site URL: https://rose-bellflower-zcdd.squarespace.com/config/settings/advanced/code-injection

Hello there!

I am facing a problem with including a file badge code for another website, the code is as follows:

<script type="text/javascript" id="ngos-ed-on-file-widget-script-17336c1f-917d-492b-bc53-225c95e103da">
 (function() {
 function async_load()
 { var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; var theUrl = 'http://www.ngosource.org/sites/default/files/ngos_ed_on_file_widget.js'; s.src = theUrl + ( theUrl.indexOf("?") >= 0 ? "&" : "?") + 'ref=' + encodeURIComponent(window.location.href); var embedder = document.getElementById('ngos-ed-on-file-widget-script-17336c1f-917d-492b-bc53-225c95e103da'); embedder.parentNode.insertBefore(s, embedder); }
 if (window.attachEvent)
 window.attachEvent('onload', async_load);
 else
 window.addEventListener('load', async_load, false);
 })();
 </script>

When I uploaded this code on the code-injection tool on my website it showed me a syntax error- so I followed the instructions below:

  • To add JavaScript to a code injection field, surround the code with <script></script> tags.

And it kind of worked- as in it appeared on the website but in a text form- see picture for reference.

Could you please help as to how to solve this issue? Also, if I'd want this code to appear in like the middle of the page instead of the footer how can I do it?

Thanks!

Screenshot 2022-06-28 130746.png

Link to comment
  • Replies 18
  • Created
  • Last Reply

Top Posters In This Topic

I'm not sure about the sending the code, but when I made the changes to the code by correcting the beginning of the code <script to <script></script> the code appeared like that in the footer of the screenshot, immediately when the I changed it.

Hope I am making sense.

I have added a pic of the code that was pasted in the footer tab, also the </script> is highlighted red.

Screenshot 2022-07-01 114732.png

Screenshot 2022-07-01 114946.png

Edited by MEDEWELL
More pics
Link to comment
13 hours ago, MEDEWELL said:
<script type="text/javascript" id="ngos-ed-on-file-widget-script-17336c1f-917d-492b-bc53-225c95e103da">

I meant this line

Screenshot_10.thumb.png.2ea40ca5686fadb74e3c0fbd5e7a072b.png

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
20 hours ago, MEDEWELL said:

Oh okay! Sorry...

The code for Line 1:

<script></script> type="text/javascript" id="ngos-ed-on-file-widget-script-17336c1f-917d-492b-bc53-225c95e103da">

It should be

<script type="text/javascript" id="ngos-ed-on-file-widget-script-17336c1f-917d-492b-bc53-225c95e103da">

 

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

So when I use the code the way you have written it, I cannot see anything change on the page, like the icon cannot be seen. 

See pic below.

The full code is as follows 

<script type="text/javascript" id="ngos-ed-on-file-widget-script-17336c1f-917d-492b-bc53-225c95e103da">
 (function() {
 function async_load()
 { var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; var theUrl = 'http://www.ngosource.org/sites/default/files/ngos_ed_on_file_widget.js'; s.src = theUrl + ( theUrl.indexOf("?") >= 0 ? "&" : "?") + 'ref=' + encodeURIComponent(window.location.href); var embedder = document.getElementById('ngos-ed-on-file-widget-script-17336c1f-917d-492b-bc53-225c95e103da'); embedder.parentNode.insertBefore(s, embedder); }
 if (window.attachEvent)
 window.attachEvent('onload', async_load);
 else
 window.addEventListener('load', async_load, false);
 })();
 </script>

 

Screenshot 2022-07-11 113935.png

Edited by MEDEWELL
Link to comment

https://rose-bellflower-zcdd.squarespace.com/?noredirect

Your site is private. Can you setup password & share url again? 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
On 6/28/2022 at 5:28 PM, MEDEWELL said:

Site URL: https://rose-bellflower-zcdd.squarespace.com/config/settings/advanced/code-injection

Hello there!

I am facing a problem with including a file badge code for another website, the code is as follows:

<script type="text/javascript" id="ngos-ed-on-file-widget-script-17336c1f-917d-492b-bc53-225c95e103da">
 (function() {
 function async_load()
 { var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; var theUrl = 'http://www.ngosource.org/sites/default/files/ngos_ed_on_file_widget.js'; s.src = theUrl + ( theUrl.indexOf("?") >= 0 ? "&" : "?") + 'ref=' + encodeURIComponent(window.location.href); var embedder = document.getElementById('ngos-ed-on-file-widget-script-17336c1f-917d-492b-bc53-225c95e103da'); embedder.parentNode.insertBefore(s, embedder); }
 if (window.attachEvent)
 window.attachEvent('onload', async_load);
 else
 window.addEventListener('load', async_load, false);
 })();
 </script>

When I uploaded this code on the code-injection tool on my website it showed me a syntax error- so I followed the instructions below:

  • To add JavaScript to a code injection field, surround the code with <script></script> tags.

And it kind of worked- as in it appeared on the website but in a text form- see picture for reference.

Could you please help as to how to solve this issue? Also, if I'd want this code to appear in like the middle of the page instead of the footer how can I do it?

Thanks!

Screenshot 2022-06-28 130746.png

Where did you get this code? 

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
  • 2 weeks later...
  • 3 weeks later...
18 hours ago, MEDEWELL said:

Hello there! 

Any hope in fixing the issue.

They provided an incorrect code. The code missing a character.

Use this new code

<script type="text/javascript" id="ngos-ed-on-file-widget-script-17336c1f-917d-492b-bc53-225c95e103da">
 (function() {
 function async_load()
 { var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; var theUrl = 'https://www.ngosource.org/sites/default/files/ngos_ed_on_file_widget.js'; s.src = theUrl + ( theUrl.indexOf("?") >= 0 ? "&" : "?") + 'ref=' + encodeURIComponent(window.location.href); var embedder = document.getElementById('ngos-ed-on-file-widget-script-17336c1f-917d-492b-bc53-225c95e103da'); embedder.parentNode.insertBefore(s, embedder); }
 if (window.attachEvent)
 window.attachEvent('onload', async_load);
 else
 window.addEventListener('load', async_load, false);
 })();
 </script>

image.thumb.png.ec128751e3fe20e1118ef1758940bc6c.png

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.