2

I have HTML page inside a folder in style library called: Employee.html, so the link is: /style library/MyProject/Employee.html, I have also JS file inside the same folder called Employee.JS, I added a content editor web part to the page and referenced this HTML page. I am referencing the JavaScript file from the Employee.html like this:

<script type="text/javascript" language="javascript" src="Employee.js"></script>

As they exist in the same folder. But when rendered in content editor web part, it's referenced based on the page inside the site pages library. So it's expecting the file to be in: sitepages/Employee.js.

What's the best practice to reference files in a relative way between custom html page and js files?

0

As you said it is a custom page: You have to know where your JS files and CSS files are. In a custom page i reference the files like: "../FEATURENAME/FILENAME.JS"

  • Thank you Daniel, but I want my solution to be intact together. I want my html pages to reference js files relatively. so whenever I give that zip file with HTML pages, css files, js files .. everything will work together when you just add the html pages in content editor webpart. got it? Is there a way to do so? – Julien Pierre Jul 5 '15 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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