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:


But, when page is uploaded and served from Apache then the javascript works:


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">-->
    <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>
    <script type="text/javascript"
    <script type="text/javascript" src="galleria/galleria-1.2.3.min.js"></script>

<header class="group">
    <div id="header-inner">
        <nav class="group">
<hr />
<script type="text/javascript">
    if (Galleria) { $("body").text('Galleria works') }
  • What OS are you using? Are you running a web server? – John Conde Apr 15 '11 at 18:54
  • I'm on a Mac... – Meltemi Apr 15 '11 at 19:08

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


or *nix:


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:


  • Using /Users/meltemi/Sites/mysite/javascriptfile.js resolves to file:///Users/meltemi/Sites/mysite/javascriptfile.js on a Mac at least. – Meltemi Apr 15 '11 at 19:07
  • Ah. i see what you're talking about... the http: got truncated at some point in my script src for jQuery. Dunno why it would work when being served by Apache?!? perhaps jQuery was cached?!? Ah well, silly mistake. Thanks for help! – Meltemi Apr 15 '11 at 19:10

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.