This is a follow up from Append within Append, Iframe within Append in Jquery
I realize the code works against most browsers but doesn't work in Firefox mobile iOS. Can anyone enlighten me how I can detect iOS Firefox so that I can display a error to user?
I read about modernizr about feature detect but it doesn't seems to detect about Firefox not writing to iframe if refreshed. So I wish to just display an error for now.
This is a follow up from Append within Append, Iframe within Append in Jquery
I realize the code works against most browsers but doesn't work in Firefox mobile iOS. Can anyone enlighten me how I can detect iOS Firefox so that I can display a error to user?
I read about modernizr about feature detect but it doesn't seems to detect about Firefox not writing to iframe if refreshed. So I wish to just display an error for now.
Share Improve this question edited May 23, 2017 at 10:28 CommunityBot 11 silver badge asked Apr 24, 2016 at 11:24 Someone SpecialSomeone Special 13.6k8 gold badges52 silver badges80 bronze badges2 Answers
Reset to default 5To detect Firefox in iOS, i only plished that after seeing user agent of Chrome, Safari and Firefox. We can see 'FxiOS' is the only difference between them, Firefox user agent string reference . All CSS hacks dont't for iOS.
My solution:
function isFirefox() {
return navigator.userAgent.match("FxiOS");
}
You can read the user-agent with JS by using the window.navigator.userAgent property.
See: https://developer.mozilla/nl/docs/Web/API/NavigatorID.userAgent
For the Firefox specific values see: https://developer.mozilla/en-US/docs/Web/HTTP/Gecko_user_agent_string_reference)
It would still be remended to do feature-checking instead of checking the user-agent string, since there might be another browser out there in which it doesn't work.
If you cannot figure out which specific feature to check for to distinguish your case, you could always check for success after trying to write to the iFrame. So simple write some random data to the iFrame, try to read it back, and if you cannot read it back you display your error message. This should work for browsers you might have never even heard of.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745401944a4626142.html
评论列表(0条)