Sander de Jong
Sander de Jong

Reputation: 75

Bug in Mobile Safari regarding HTML LINK

My native iPhone app displays HTML files using UIWebView. These HTML files are stored locally on the iPhone (they ship with the app).

Now I'm also trying to use a central CSS file in the HTML files, using something like: <link href="../../stylesheet.css" rel="stylesheet" type="text/css">

In Safari, this works, the HTML files look OK. In Mobile Safari (both on the simulator and a real device) this does not work: no CSS file found. So I tried the following: Store the CSS file in the same directory as the HTML file (plus different LINK of course): no problem. Store the CSS file one directory higher: no problem, works in both Safari and mobile Safari. Store the CSS file one directory higher: does not work in mobile Safari, but no problem in Safari. What gives? In ../.. are various other directories that I created and use. Note: ../.. points to a directory that is an immediate subdirectory of the bundle. ../.. does not try to go into the bundle directory.

Any ideas? Anyone who saw me demonstrate this was also baffled.

Upvotes: 0

Views: 567

Answers (1)

Sander de Jong
Sander de Jong

Reputation: 75

Solved! Caused by a bug of my own combined with a mobile Safari "feature".

The HTML file was opened with a path containing // That was my bug. Using ../.. to traverse back caused the strange behavior observed above. That's a mobile Safari feature for you. I am used to // being treated as a single /, but apparently mobile Safari begs to differ.

Just cost me some hair... never mind.

Upvotes: 1

Related Questions