Forum Moderators: open
You could test if the request for the .js file has a referrer from a legitimate file, and deny it otherwise, but it is not foolproof. Some browsers and proxies doesn't send the referrer header, and it can be faked.
So, something can be done, but nothing that is perfectly safe.
René