/    Sign up×
Community /Pin to ProfileBookmark

very confused!

can someone smarter than me explain why I’m having so much trouble with this problem!

I include 5 javascripts for my website, and 4 of them work fine. I do this by referencing them as external files and the scr=”webserver location”

for example:

[CODE]
<script src=”http://localhost/mysite/view/default/accordion.js”></script> [/CODE]

The 5th one, called [B]clock.js[/B] I simply cannot reference with a webserver address – in other words this does not work:

[CODE]
<script src=”http://localhost/mysite/view/default/clock.js”></script> [/CODE]

however if i reference it with a [B]partial filepath[/B] address it does work, eg:

[CODE]
<script src=”house/scripts/clock.js”></script>[/CODE]

… now the problem is, the partial filepath is no good for some parts of the website (different levels, making the partial filepath invalid).
If I try a full filepath like this:

[CODE]
<script src=”C:/wamp/www/mysite/house/scripts/clock.js”></script>[/CODE]

the script doesn’t work at all!!
any ideas??

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@mrhooJan 13.2009 — You are referencing it with the directory /[B]house[/B]/ in the relative link, but not where you have the absolute path.
Copy linkTweet thisAlerts:
@FangJan 13.2009 — Is the path correct; you use 2 different ones?

Have you set the base element?

Try this:
&lt;base href="http://localhost/mysite/" /&gt;
&lt;script src="house/scripts/clock.js"&gt;&lt;/script&gt;
Copy linkTweet thisAlerts:
@slaughtersJan 13.2009 — Well, you learn something new every day. There is a BASE HTML tag ?

Can see how it can be useful.

Can see how it could be confusing.
×

Success!

Help @bazaarboy 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.18,
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,
)...