Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

snail22

macrumors member
Original poster
Aug 7, 2012
62
7
Sorry for the cumbersome title...

"../" is used to specify a parent directory in HTML correct? Why is Safari not recognizing this notation?

For example, I just made a simple HTML file in TextEdit:

<html>
<body>
<img src="../folder/image.jpg"></img>
</body>
</html>

Opening the file in Chrome displays the image, but Safari doesn't.

I found someone else having the exact same issue here but nobody's responded.
 

Handoff

macrumors newbie
Dec 3, 2019
29
21
How does your directory tree look like?

btw img tags are self closing, eg.:


HTML:
<html>
<body>
<img src="../folder/image.jpg" />
</body>
</html>
 

snail22

macrumors member
Original poster
Aug 7, 2012
62
7
Yes, well... this is why I don't do HTML coding by hand.

My example should work if I have two folders in the same directory, one with the html file and one with the image. And it does work... in Chrome. So why is Safari being stubborn?

Interestingly, if I link to the html file from a different file in the parent directory, it displays as it should. But when I open it directly it does not. So for example:

root folder>
--page1.html
--images>
----image.jpg
--folder>
----page2.html

If page2.html contains <img src="../images/image.jpg">, the image will not display if I open page2.html directly, but if page1.html contains a link to page2.html and I follow the link, then the image will display.
 

Handoff

macrumors newbie
Dec 3, 2019
29
21
That's strange, just tested it in Safari and it rendered the image fine. Does it show any error in the safari's console?
 

Kuzbad

macrumors member
Jun 11, 2009
62
20
Works fine for me too. Did you ever change your <img> tag to be self-closing?

Try right-clicking on the broken image and doing copy image location (or open in new tab) to see what Safari is trying to load.
 

snail22

macrumors member
Original poster
Aug 7, 2012
62
7
Here's a zip file with the exact set up I described above. As I said, when I open page2 directly, the image doesn't load (I get the small blue box with a ?). But if I right click and select "open image in new tab", then the image loads. And if I open page2 via the link in page1, then the image loads correctly.

All my software is updated (Catalina and Safari 13.1). I even booted into Mojave from an external disk that I made to run a couple 32-bit apps, and found the same behavior. I'm baffled that nobody else is seeing this!
 

Attachments

  • root.zip
    353.2 KB · Views: 201

Handoff

macrumors newbie
Dec 3, 2019
29
21
It works for me:
1589655274666.png


Could it be some safari extension blocking or a permission issue on the folder?
 

snail22

macrumors member
Original poster
Aug 7, 2012
62
7
I can't think of any possible culprit that would cause the same issue on a completely seperate system on an external drive. My Mojave system is practically a fresh install.
[automerge]1589658223[/automerge]
Yikes... looks like my Adblocker was the culprit after all. Probably seems obvious, but I had ruled it out since the problem was happening on a totally different system with no Safari extensions (still no clue how this could have been affected). Anyways, I tweaked a couple settings off and on and the problem is gone for now.
 
  • Like
Reactions: Handoff

snail22

macrumors member
Original poster
Aug 7, 2012
62
7
An update in case anyone with this issue comes across this thread:

I was wrong, it wasn't Adblocker or any other extension that was preventing the filepaths from working. I discovered this when the problem resurfaced immediately after a fresh install of Big Sur.

The solution is here: https://ccm.net/faq/36342-safari-how-to-enable-local-file-access
Two simple steps - enable the "Develop" menu in Safari prefs and then select "Disable local file restrictions" from the menu.

Why these restrictions are enabled by default is beyond me. Apple really seems to be going overboard with security features lately. I guess not enough people browse local HTML files for this to be a widespread inconvenience.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.