/    Sign up×
Community /Pin to ProfileBookmark

../image.gif loads fine, ../external.js doesn’t

Hi,

I’m experiencing some problems with an external .js

On my Cpanel account I have a number of Addon Domains. Each domain’s index.htm needs access to one and the same .js file, which is located in the root.

This is the structure of my Cpanel account:

public_html/external.js

public_html/domain_1/index.htm
public_html/domain_2/index.htm
public_html/domain_3/index.htm
public_html/domain_4/index.htm
public_html/domain_5/index.htm
…and so on

In each index.htm I’ve put the following code:

<html>
<head>
<script language=”javascript” src=”../external.js”></script>
</head>
<body>
<img src=”../image.gif” onClick=”my_external_function()”>
</body>
</html>

The image loads fine, but when I run the function I get a javascript error. Why is that? If the image loads using “../” then the external .js should run fine as well, right?

Would appreciate any input on this matter.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@fredmvFeb 17.2005 — Got a link to the page in question? There are an array of things that could be going wrong.
Copy linkTweet thisAlerts:
@magoauthorFeb 17.2005 — Just got this reply from customer support:

"...it appears that to load a javascript file it must be in a webviewable directory." So I guess there is now way to do this then. Real shame.

And the image which I thought was loading without problem - well it turns out that if you are calling the image src from your index file (path: public_html/domain/index.htm), then it doesn't matter if it says src="../image.gif" or src="image.gif" in your index file - both would refer to public_html/domain/image.gif.

I had a two copies of the same image on my server. One was located in public_html/domain/image.gif and one in public_html/image.gif. Mistakely, I thought that the index file was loading the image from public_html/image.gif.

Sorry about the misunderstanding.
×

Success!

Help @mago spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...