...

View Full Version : quick question (cant describe it 4 subject!)



hypedup.co.uk
10-12-2002, 04:47 PM
to load a picture from the directory below the page you use "../picture.jpg" but what do i put instead of "../" to make it load from the man (first) directory?

thanks, paul

murphyz
10-12-2002, 05:12 PM
Do you mean going back several folders?

It really depends on where the image is.

Say you have following structure:

www.yourdomain.com
which has the folders 'pages' and 'images'.

'images' folder contains logo.jpg
'pages' folder consists of index.htm and another folder called 'morepages' which contains the page 'news.htm'

To insert the logo onto the news page, you would need to specify that you want to go two folders back, and then into the images folder as such
img src="../../images/logo.jpg"

So try working out from this example where you need to go in order to be able to see the correct folder and image.

Mxx

hypedup.co.uk
10-12-2002, 05:16 PM
i will try and explain myself more. its in a .js file which will be used for all pages (which are in different directories) and instead of putting the full address for everything in it, i thought there would be a shortcut way like "../"

murphyz
10-12-2002, 05:47 PM
Nope still not really getting you - So, you have one .js file which has an image you need for lots of pages?

Each page will have a link to the .js file so you can simply type the location of this file instead of using any ../ in it!

so, instead of typing src ="../image.jpg" which will only work for files in that folder, why not type src="http://www.yourdomain/folder/image.jpg" so that every file you have will link direct to the image?

...if this is what you mean?

Forgive my lack of understanding - my brain is fried from figuring out how to set up a forum.

Mxx

hypedup.co.uk
10-12-2002, 05:52 PM
thats ok, ive got a headache so my brains not functioning much better either!!

i know you can type the whole address of the picture in, i just thought that if you can use ../ to go back one directory that there was something like ./ that would take you back to the top directory. if not, i will just use the full address. just wanted to know if there was a way.

thanks anyway, paul

Galdo
10-12-2002, 05:57 PM
To get to the top directory (the folders within the top directory) use:

<img src="/something.jpg">

:D

hypedup.co.uk
10-12-2002, 06:02 PM
i tried that galdo but it didnt work

murphyz
10-12-2002, 06:03 PM
I don't know of a way that you can do that and just go for using the full address. Although using templates or CSS may make the job slightly quicker if you have lots of pages.

Mxx

Galdo
10-12-2002, 09:16 PM
Originally posted by hypedup.co.uk
i tried that galdo but it didnt work

Yes it does work, give me an example of what you are trying to do.

hypedup.co.uk
10-12-2002, 10:11 PM
heres part of the code in the javascript i am using on all pages:

document.write('<script language="javascript" src="/all/javascript.js"></script>');
document.write('<link rel="stylesheet" href="/all/stylesheet.css" type="text/css">');

ive put the / at the start like you suggest but it now means it doesnt work for any pages - no matter what directory they are in!

glenngv
10-14-2002, 07:49 AM
Galdo is correct.

are your .js and .css files located in the all folder under the root directory? could you illustrate your directory structure?

hypedup.co.uk
10-14-2002, 04:21 PM
yes, the .js and .css files are in the all folder (www.website.com/all) and the html files are in the root directory or in other folders (eg www.website.com/games). i also have a menu which i have the same problem with (although i havent tried putting a / at the start for the menu links).

the problem is if i put the whole address in, i cant look at my site from my computers hard drive as it will be looking online instead.

hypedup.co.uk
10-14-2002, 08:12 PM
im sorry, it did work - sorta! the reason why i thought it didnt was cos it was making pic locations etc go to "C:/picture.gif" on my local machine and not "C:/website/picturegif".

is there anyway of getting it to work on both the live website AND my local machine?

Roy Sinclair
10-14-2002, 08:50 PM
You don't happen to have a <base ...> tag in those web pages do you?

hypedup.co.uk
10-14-2002, 08:52 PM
no, no <base> tags

PauletteB
10-15-2002, 09:17 AM
I suspect the scenario may be the same as mine. One of my web sites is hosted through my isp, so my top level directory is actually my username. Using slash /foobar.gif, browsers are (obviously) looking for the root, but I actually cannot write to the root. That level is where the isp's usernames are located.


Normal url: http://www.foo.com/mywebsite/foobar.gif
Using /foobar.gif - not found: http://www.foo.com/foobar.gif

Maybe the same 'problem' - not a domain, but a sub-domain (for lack of a better word), and that being the case, the root is one level higher that my top level directory.

To confirm this, when I attempted a /foobar.gif, the placeholder's properties showed that the browser had looked in the root (http://www.foo.com/foobar.gif), and only my isp can write there. Hence the reason I cannot reference a slash as a global shortcut to the root.

Make sense? and could that be the problem?

Roy Sinclair
10-15-2002, 02:49 PM
If Paulette has figured out the problem then using that <base> tag I mentioned before might be your solution.

Revelle
10-15-2002, 03:01 PM
site to work Live and Local

--------------------------------------------------------------------------------
is there anyway of getting it to work on both the live website AND my local machine?
--------------------------------------------------------------------------------



Having the root-way of linking for your JS won't work on your local drive due to the page going to your root to look for these files while they rest someplace else.
To have it work, simply put your folders and images in/on your root directory and then it should work (offline) and as for the LIVE part, that has been explained already

hypedup.co.uk
10-15-2002, 08:11 PM
paulette, yes thats the same sort of problem.

roy, can you explain more on what you mean by using the base tag?

thanx

Roy Sinclair
10-15-2002, 10:13 PM
I did some experimentation and found the base tag didn't work the way I thought it should. I was hoping you could use it to specify the additional part of the URL to make it work but it doesn't work that way and wouldn't pick up the image.

I suspect you'd be better off adding the missing part of the live url to your local development environment and then adjusting all the relative urls to contain that additional level.

hypedup.co.uk
10-15-2002, 10:22 PM
thanks for having a look roy. ive also just decided to have 2 .js files - one for offline and one for online and just switch between the two.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum