我使用一些 js 在我正在制作的网站上插入 safari 特定样式。当我在 iPhone 上的移动 Safari 中打开该网站时,样式工作正常。
但由于某种原因,当我在 facebook 上发布指向该网站的链接,然后通过我的 facebook 应用程序打开链接时,样式被忽略 - 为什么?
If you mean in the internal web frame of Facebook before you click 'Open This Link in Safari' then it's because it's not Safari, it's just a stock and standard Web View with no access to any of the other Safari features (that's why it's often quicker to open the link in Safari).
EDIT: I decided to dig a bit further (this has probably been done before but I didn't find it on the first page of Google so). I have a site with practically zero traffic so I used that, monitored through Google Analytics to see what my browser agent would come back as. The only device connect was my iPhone at that point and it sends the browser agent as 'Mozilla Compatible Agent' for Browser, with iPhone as the OS. I then logged on through Safari and checked again.
Looks like for the UIWebView Apple decided not to bother putting the Safari user agent, which is weird. Or weirdish, I suppose it has a lot less functionality so not showing it as a stock agent might be a good thing.
Picture: