Reputation: 465
I am running a tomcat server and my localhost base domain is :
C:/apache/webapps/ROOT/
My webpage is also present here.
However the javascripts are present in an external location.
D:/something/something
And i am importing them the following way
<script src="D:/something/something/js1.js"></script>
In IE the page loads fine and able to locate the scripts, however with chrome it fails. On debugging I see that chrome tries to append the following:
http://localhost:8080/D:/something/something
How do i get it to work on chrome without copying the scripts to base location?
Upvotes: 1
Views: 148
Reputation: 10487
For doing anything useful from within the JS code, you'll most likely have to obey the same origin policy. This means you'll have to configure your Tomcat so that it serves the scripts, too.
If you really insist on reading the scripts from local files, that's what file://
URLs do.
Upvotes: 2
Reputation: 1395
You can't do this because you will search for D:/something/something/js1.js
in the user/client computer.
You can do it calling (read and print) the file via PHP (D:/something/something/js1.js.php
) or any other server side programming language or installing a webserver in your external location to call the file via URL like myCDN.mydomain.com.
EDIT: If you will only work in localhost, use @Pointy and @Konstantin K solutions :)
Upvotes: 1