absolute file urls treated as relative by browsers

Off-Topic discussions about science, technology, and non Debian specific topics.
Post Reply
Message
Author
bitrat
Posts: 63
Joined: 2023-07-20 09:41

absolute file urls treated as relative by browsers

#1 Post by bitrat »

Hi,

apologies that this isn't a debian specific question, but I'd really like some advice!


I have a script that generates absolute file URLS as hrefs in an html file.

I had a similar script that worked great when the links were relative. Now I want to span multiple drives.

However, if I click on the link, the URL is treated as relative and the browser prepends the current path, and so the link doesn't work.

If I inspect the link, sure enough, the browser has added a dot to the front.

However, if I view source, as expected, the dot isn't there and the link works as intended when clicked on.

This happens in firefox and chrome, so I suspect it's some kind of same origin policy.

Is there a way of disabling or working around this behaviour? It's extremely annoying, as I want my links to span more than one disk.

No, I'm not planning to run an http server to access the files for me. :)


Best wishes,
bitrat

Aki
Global Moderator
Global Moderator
Posts: 2203
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 50 times
Been thanked: 292 times

Re: absolute file urls treated as relative by browsers

#2 Post by Aki »

Moved from "Programming" to "Off-Topic" sub-forums.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

lindi
Posts: 271
Joined: 2022-07-12 14:10
Has thanked: 1 time
Been thanked: 53 times

Re: absolute file urls treated as relative by browsers

#3 Post by lindi »

Please provide the html file.

Dai_trying
Posts: 1034
Joined: 2016-01-07 12:25
Has thanked: 3 times
Been thanked: 9 times

Re: absolute file urls treated as relative by browsers

#4 Post by Dai_trying »

lindi wrote: 2023-11-11 08:08 Please provide the html file.
And the script might be helpful too.

bitrat
Posts: 63
Joined: 2023-07-20 09:41

Re: absolute file urls treated as relative by browsers

#5 Post by bitrat »

Assuming the html file and gifs are in /media/user/BACKUP/thumbs, this works:

Code: Select all

<a href="file:///media/user/BACKUP/KIF_0094.JPG"><img src="./KIF_0094.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/BACKUP/KIF_0097.JPG"><img src="./KIF_0097.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/BACKUP/KIF_0098.JPG"><img src="./KIF_0098.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/BACKUP/KIF_0099.JPG"><img src="./KIF_0099.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/BACKUP/KIF_0100.JPG"><img src="./KIF_0100.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/BACKUP/KIF_0104.JPG"><img src="./KIF_0104.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/BACKUP/KIF_0106.JPG"><img src="./KIF_0106.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/BACKUP/KIF_0107.JPG"><img src="./KIF_0107.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/BACKUP/KIF_0108.JPG"><img src="./KIF_0108.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/BACKUP/KIF_0109.JPG"><img src="./KIF_0109.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/BACKUP/KIF_0110.JPG"><img src="./KIF_0110.gif" width="150"  border="1"  ></img></a>
..but this doesn't:

Code: Select all

<a href="file:///media/user/DATA/KIF_0094.JPG"><img src="./KIF_0094.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/DATA/KIF_0097.JPG"><img src="./KIF_0097.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/DATA/KIF_0098.JPG"><img src="./KIF_0098.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/DATA/KIF_0099.JPG"><img src="./KIF_0099.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/DATA/KIF_0100.JPG"><img src="./KIF_0100.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/DATA/KIF_0104.JPG"><img src="./KIF_0104.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/DATA/KIF_0106.JPG"><img src="./KIF_0106.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/DATA/KIF_0107.JPG"><img src="./KIF_0107.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/DATA/KIF_0108.JPG"><img src="./KIF_0108.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/DATA/KIF_0109.JPG"><img src="./KIF_0109.gif" width="150"  border="1"  ></img></a>
<a href="file:///media/user/DATA/KIF_0110.JPG"><img src="./KIF_0110.gif" width="150"  border="1"  ></img></a>
/media/user/BACKUP and /media/user/DATA are different physical disks. I'm assuming different logical disks would show the same behaviour, but I haven't checked.

It may be significant that I haven't bothered to add the html prelude and postscript to the file (ie, it's not well formed html). This may well be a problem, but I don't have time to experiment right now. That would be the only salient detail that providing the generating script itself would offer.

I've finished with it for now, but I'll update here with any new info. I won't mark it as solved as I'd still like to know the formal constraints behind this disk spanning barrier. That would be my key question.

Post Reply