Mobile app version of vmapp.org
Login or Join
Samaraweera270

: Javascript not loading from local drive I'm overlooking the obvious...Modifying an index page on local hard drive before uploading it to server. And the javascript is not loading. This doesn't

@Samaraweera270

Posted in: #Javascript #Jquery

I'm overlooking the obvious...Modifying an index page on local hard drive before uploading it to server. And the javascript is not loading. This doesn't work:

file:///Users/meltemi/Sites/mysite/index.html


But, when page is uploaded and served from Apache then the javascript works:
www.mysite.com/index.html

Site directories are identical both locally and on remote server. I have tried this with Safari 5.0.5 & Firefox 4.0.

code excerpts, though I don't believe it's a code issue:

<!DOCTYPE html>
<html lang="en">
<!--<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" media="screen" href="css/main.css" />
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script type="text/javascript"
src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="galleria/galleria-1.2.3.min.js"></script>

</head>
<body>
<header class="group">
<div id="header-inner">
<nav class="group">
...
</nav>
</div>
</header>
<hr />
<script type="text/javascript">
if (Galleria) { $("body").text('Galleria works') }
</script>
</body>
</html>

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Samaraweera270

1 Comments

Sorted by latest first Latest Oldest Best

 

@Sarah324

You need to specify the full path including the drive. The file: part is unnecessary.


C:/Users/meltemi/Sites/mysite/javascriptfile.js


or *nix:


/Users/meltemi/Sites/mysite/javascriptfile.js


Ideally you'll develop in a web environment and then can use a path relative the webroot which will be the same regardless of whether the site is local or on the live server:


/javascripts/javascriptfile.js

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme