I recently bought the Back to Top Stack (RWExtras) which includes the option to export code for non stacks pages. I’ve followed the instructions but can’t seem to get it to work on the standard RW blog page. I’ve included the HTML code for the button in the sidebar and added CSS and javascript as per the instructions in the stack.
Page source shows a Can’t find variable error at the beginning of the javascript (screenshot below).
Not familiar with the stack/non-stack and can’t make out from the screenshot but does it need to be customised for the page you want it to be on (note the this.pathname.replace) or include the <div>BacktoTopAnchorPoint that it is targeting to get back to the top?
On a stacks page this stack adds a scrolling ‘back to top’ button and it’s just a matter of adding the stack and customising the button as required. From a stacks’ page it is possible to generate HTML, CSS and javascript code (displayed in preview mode when the ‘view generated source code’ is toggled) for use on a non stacks page, such as the default RW blog page. There is no reference to the need to customise the code for the page, bearing in mind that the page generating it won’t be the one where it’s used. I assume, therefore, that the code is not page dependent.
That is not Javascript code, that is HTML and CSS.
Because global.js is loaded before your ‘back to top’ code, this error causes all other Javascript on the page to cease working. Hence jQuery is not working and the first line of your ‘back to top’ code fails.
It should be a very simple fix, now you know what the issue is and what to look for. I strongly suspect you entered this wrong in your site settings or Page Inspector and forgot about it.
Thank you for pointing this out. However, I’ve completely removed all code from the global.js but this doesn’t seem to have resolved the problem. The back-to-top button is still not appearing and the same error is still showing when I view the Page source.