0

I am trying to use the HillbillyTabs.4 JS file in my SharePoint Online site collection (not the root collection https://tenant.sharepoint.com, but https://tenant.sharepoint.com/sites/teamsite).

All scripts and files are stored in that team site (/sites/teamsite/SiteAssets/js or /sites/teamsite/SiteAssets/css).

I manage to get the tabs running fine by using a CEWP and referencing the JS file that loads all the scripts and css on the page. It runs fine and dandy. But a few times, when I refresh the page or navigate back to it, SharePoint for some reason starts trying to reference the files in the root site collection.

That is, SharePoint starts looking for the scripts and css from https://tenant.sharepoint.com/SiteAssets/js or https://tenant.sharepoint.com/SiteAssets/css.

Nothing has changed in the CEWP, the original script file referenced in the CEWP is fine as well, that hasn't changed. No one else is working on the site (its still in dev). There is no other JS running on the page except the referenced in CEWP.

The weird thing is, it seems to work some times and not always. Which to me means there is something interfering with its execution but everything is out of the box so that doesn't make sense either. Any ideas would be appreciated!

EDIT: As soon as I posted this, I noticed something very peculiar. If I navigate to the url tenant.sharepoint.com/sites/teamsite, it doesnt work. But if I navigate to the url tenant.sharepoint.com/sites/teamsite/pages/default.aspx, it works!! WHAT

2
  • What's the URL in CEWP? May 9, 2018 at 21:29
  • I have tried relative URL as well as absolute (which also resolves to the relative url (/sites/teamsite/SiteAssets...) There seems to be something weird happening to the JS references when navigating to the site using the friendly URL (as per my edit)
    – Krishant L
    May 9, 2018 at 22:02

1 Answer 1

0

Just in case someone comes across the same issues as I did. Managed Navigation and friendly URL is the root of this. In my search, I came across Waldek's post regarding Managed Navigation which gave me what I needed to know. In my CEWP, although I was using an absolute URL, within the JS itself, I was still using relative URLs. And that is what caused the issue (its a noob mistake on my part).

I had to change the URLs in the JS file I was referencing (including the CDN references for JQuery) to be absolute and that resolved the issue for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.