howeverbighoweversmall Posted October 18, 2019 Share Posted October 18, 2019 To begin I must say I have no real experience coding, so if you need more information or something different, please ask! I have been using three different third party widgets (like affiliates or hover maps) and have been injecting their code into the website. My problem is when you load the website, the things with code don't load until you refresh the page. Example 1: On the home page, there is supposed to be a map that shows up before the slide gallery underneath it. If you hit refresh the map shows up, but it doesn't show up when you first go to the page. https://www.howeverbighoweversmall.com Example 2 & 3: Here on the product page I want to have the affiliate links work under Book Your Activity or Book Your Accommodation. Again, they only work when you refresh the page. Is there something I can do from my Squarespace editor or is this something wrong with all of the code? https://www.howeverbighoweversmall.com/get-your-itinerary/8-days-in-tuscany Here is the code for Booking.com for example: <ins class="bookingaff" data-aid="1890417" data-target_aid="1890417" data-prod="map" data-width="100%" data-height="590" data-lang="ualng" data-dest_id="0" data-dest_type="landmark" data-latitude="43.7679178" data-longitude="11.2523792" data-landmark_name="Cape Town" data-mwhsb="0" data-address="Cape Town"> <!-- Anything inside will go away once widget is loaded. --> <a href="//www.booking.com?aid=1890417">Booking.com</a> </ins> <script type="text/javascript"> (function(d, sc, u) { var s = d.createElement(sc), p = d.getElementsByTagName(sc)[0]; s.type = 'text/javascript'; s.async = true; s.src = u + '?v=' + (+new Date()); p.parentNode.insertBefore(s,p); })(document, 'script', '//aff.bstatic.com/static/affiliate_base/js/flexiproduct.js'); </script> Thank you in advance!! Link to comment
brandon Posted October 18, 2019 Share Posted October 18, 2019 Hi @howeverbighoweversmall. The issue has to do with AJAX loading. You can disable it, or you can edit your code to take AJAX loading into account. I hope this helps. -Brandon paul2009 1 If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' (top-left) Link to comment
bigrig008 Posted January 11, 2020 Share Posted January 11, 2020 Hi @brandon- how can i access that link you posted. It says i don't have permission to read the article: https://forum.squarespace.com/topic/3077-choosing-an-implementation-method-for-custom-javascript-on-ajax-loading-templates/?do=findComment&comment=17885 Link to comment
brandon Posted January 11, 2020 Share Posted January 11, 2020 The summary is, basically, to wrap your code like this: <script> window.Squarespace.onInitialize(Y, function() { //Your code here... }); </script> helloVladstudio 1 If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' (top-left) Link to comment
Johster Posted June 10, 2020 Share Posted June 10, 2020 (edited) Hi there! I'm glad I found this post. I have the same issue now with this code from Tryinteract: <div id="interact-5eda865db27ec100144ca6e2"></div><script type="text/javascript">var app_5eda865db27ec100144ca6e2;(function(d, t){var s=d.createElement(t),options={"appId":"5eda865db27ec100144ca6e2","width":"800","height":"800","async":true,"host":"quiz.tryinteract.com","mobile":true,"footer":"show"};s.src='https://i.tryinteract.com/embed/app.js';s.onload=s.onreadystatechange=function(){var rs=this.readyState;if(rs)if(rs!='complete')if(rs!='loaded')return;try{app_5eda865db27ec100144ca6e2=new InteractApp();app_5eda865db27ec100144ca6e2.initialize(options);app_5eda865db27ec100144ca6e2.display();}catch(e){}};var scr=d.getElementsByTagName(t)[0],par=scr.parentNode;par.insertBefore(s,scr);})(document,'script');</script> Does anybody know how to wrap up that one to work fine? Thanks so much as I also don't know anything about coding. Best, Johannes Edited June 10, 2020 by Johster Link to comment
JamesPen Posted October 14, 2021 Share Posted October 14, 2021 Hi, I'm also having this issue but the solution of wrapping it in On 1/12/2020 at 7:24 AM, brandon said: window.Squarespace.onInitialize(Y, function() { //Your code here... }); doesn't work for me as the code block doesn't execute any javascript unless refreshed. Can't even log to the console, so the function is not bound (I'm assuming the onInitialize function is an event binding, I'm only moderately proficient with javascript). Could you repost what you had linked at https://forum.squarespace.com/topic/3077-choosing-an-implementation-method-for-custom-javascript-on-ajax-loading-templates/?do=findComment&comment=17885 @brandon ? Still can't access that link. 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