When referencing a Javascript file from your Master Page, the relative path may be different depending on where your your page is located within the project.
This neat little solution posted by Paul Murphy on his blog here, fixes the issue by resolves the URL on the site and not the application. This includes if your website sits in a virtual directory too! Magic.
<link href=”../styles/layout.css” rel=”stylesheet” type=”text/css” />
<script type=’text/javascript’ src=’<%=ResolveUrl(“~/scripts/common.js”) %>’

