Hack Forums
Having Trouble With Changing JS Links in Index.html - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Webmasters (https://hackforums.net/forumdisplay.php?fid=141)
+---- Forum: Website Construction (https://hackforums.net/forumdisplay.php?fid=50)
+---- Thread: Having Trouble With Changing JS Links in Index.html (/showthread.php?tid=5387027)



Having Trouble With Changing JS Links in Index.html - youngbandz - Aug 26, 2016

I have a website in which some javascript is used. At the bottom of index.html there is a section for the link source, (as seen here)

https://gyazo.com/aa66e1e1a10360b0a51f199c6284afb6

and I have a folder with the exact same Javascripts in my website's folder
(seen here)

https://gyazo.com/7804e640cff00d73e56d6f8236793b6d

All I want to do is change the javascript sources to the ones in my js folder, but for some reason it won't work when I replace it with just "js/myfile.js" I would like to do this so I could upload my website files to multiple domains, so the source won't be domain specific like it currently is now.


If anyone understands this and could help, that would be greatly appreicated, or if more information is needed let me know.

Thank you much for your time.✌


* - Dinastia- - Aug 27, 2016

"but for some reason it won't work"

Try to narrow it down. Check if it's a directory problem: open the page with the inspect element tool and try to open the link of the javascript files in a new tab.


* - Soulmate~っ☆ - Aug 27, 2016

First figure out if it's a problem with the directory or the CSS. Does it work if you take it out of the js folder back into public_html then embed it as myfile p.js? (wherever your index is)

If not then it's a problem with the CSS
If yes it's a problem with the directory and instead of just using /js/myfile.js try the full directory as public_html/js/myfile.js or mywebsite.com/public_html/js/myfile.js


* - grady - Aug 28, 2016

If you're linking it as "js/myfile.js" then you have to be sure that you're not currently in what the website or browser recognizes as a directory.
If your current URL looks like "http://site.com/search/" then when it tries to resolve the file, it'll look for "http://site.com/search/js/myfile.js"

Make sure to set permissions for your js files correctly, so the web user isn't denied access from trying to view them.


* - youngbandz - Aug 30, 2016

I believe it is a problem with the CSS, not the directory. I have tried many different solutions to the directory, (listed above) and also some other ones with help from someone who knows basic html and javascript. I am wondering what should I do now knowing it is a problem with the css?


* - grady - Aug 30, 2016

If you're attempting to link just the JS files, it won't be an issue with your CSS.
Try settings it from the directory root:
/js/myfile.js which will make a request to example.com/js/myfile.js regardless of the folder you're currently located in.


* - youngbandz - Aug 30, 2016

I have tried that. And it still wont work. I was wondering if anyone could help me on Teamview or skype