im using some js to insert safari specific styles on a website im making. when i open the site in mobile safari on an iphone, the styles work fine.
but for some reason, when i post a link to the site on facebook, and then through my facebook app open the link, the styles are ignored – why?
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:
