Set textbox focus in mobile safari - iphone

Hey, I was wondering how to set the focus to a text box in Mobile Safari.
I've tried document.myForm.myTextArea.focus() which works in regular Safari, but it does not seem to work in Mobile Safari.
To clarify, I want to set focus to a text box as soon as the user loads a page, and have the iPhone keyboard pop up.

Just found this previous post stating this is a bug in webkit. Sorry for not doing a more thorough search.
http://discussion.forum.nokia.com/forum/showthread.php?t=127724

I found a bug report with the iUI project relating to this.
It seems that a focus() call will not work if called from the onload event or if called via a timer.
http://code.google.com/p/iui/issues/detail?id=129
Update: Although I have no source for this, I am told (by people who have tried it) that in iPhone OS 4 the problem with focus() and onload should be fixed.

Nothing to do with the timer, focus() doesnt work at all... im doing mine through an AJAX function. i guess my web application will have to suffer in mobile safari.
Bye the way, this also affects HP webOS devices and any other device using mobile safari

Related

Unity WebGL Mobile browser workaround and keyboard input fix?

Hey everyone so I read that unity doesn't really support mobile browsers for WebGL games. im using 2020.1.4.And sure enough, the game gets a bit distorted by not being scaled properly. it's like the camera is bigger so it shows on the screen that blue color. I tried some things, setting width and height to auto or removing config.devicePixelRatio = 1; as suggested by a friend but nope! still looks horrible! And if that wasn't enough the keyboard doesn't show up when clicking on form fields. i tried this one
https://github.com/eforerog/keyboardMobileWebGLUnity
which displayed an error when pressed on and this one
https://github.com/dantasulisses/WebMobileInputFix which just didn't even compile!
Any ideas, please?
I did my research and tried every plugin I could find. I used Unity 2020.3.28f1 and tested both on Android-phone and iPhone.Here is my report.
These plugins don't work:
https://unitylist.com/p/f58/Unity-webgl-inputfield
https://github.com/eforerog/keyboardMobileWebGLUnity
https://github.com/dantasulisses/WebMobileInputFix
This plugin works, but you should use different settings for IOS and Android on same input field game object. If you use "prompt", it works for IOS only, and "overlay" works for Android only. Look for documentation in page:
https://github.com/unity3d-jp/WebGLNativeInputField
And this plugin works best at the moment. Yes, it is a bit ugly though, but it works.
https://github.com/kou-yeung/WebGLInput
And there is a fix for Unity 2021 for it:
https://github.com/kou-yeung/WebGLInput/releases/tag/1.0
There's a keyboard that overlays, when using it you just need to tap the notification to access it and then click the "back" button to hide it https://play.google.com/store/apps/details?id=com.fishstix.gameboard
I made this project that simply recreates a keyboard using buttons in unity.
I implemented it in a WebGL build successfully.
https://github.com/thetimeste/WebGL-Build-Keyboard-Unity.git
I would recommend using the native js window.prompt() fields as of writing. They have great cross-platform support, allow for extra features like special characters, emojis, copy and paste etc. and are pretty easy to set up. Once (or honestly if ever) Unity adds their own reliable implementation you can easily remove this lightweight implementation.
Create a .jslib file that has a function opening a window.prompt(description, currentText)
Return the result at the end of that function back to a unity object with a recipient script
Make a derivation from Unity's event system overwriting the OnApplicationFocus(bool focus) function (leaving it empty), to fix a sneaky Chrome Android bug.
That's it. The result should look something like in this demo: https://pop.demo.neoludic.games
If you want to save some development time on a feature that really should just be native in Unity, you can also check out my plugin based on the method above. https://neoludic-games.itch.io/pop-input
I also need to enable mobile virtual keyboard for running webgl on mobile device.
I've tried the code from your mentioned url. It gives you some idea on how to do
it, but the code are totally buggy and unusable. Now I am trying to implement it
by myself.

mobile web app - keyboard not appearing

I have a mobile web application, working well on simulator 5.1/6.0, xcode 4.5 for iphone.
But when I test on a real device (3gs, ios 5.1), I get a strange behavior: anywhere I place an input field html element, where I need the user to fill in something, I tap the field, it gains focus (I see the cursor), but the touch-keyboard does not come up and I can't type anything. If I try it on the sim, all is fine, the kb comes up.
I am not sure how to diagnose this... tried googling for some answers, haven't found any :(
any ideas?
thanks...
ok found the issue, seems like the app was not created using the latest Xcode template (it is a legacy app), so I removed the MainWindowxxx.xibs which I don't need, and used the code from a new XCode app template to initialize the app by programmatically creating the main view controller, and setting it as the window's rootViewController. And, of course, call [self.window makeKeyAndVisible]

Flash does not reappear after hiding on FB canas app using wmode=direct

I'm working on a FB canvas app using Flash with 3D graphics.
I must embed my SWF with param wmode="direct".
On FB, when opening FB UI dialog (such as: purchase credits), FB automatically hides (visibility=hidden) the flash, and after dialog closes, FB returns the old visibility value.
On Chrome and Firefox it works, but on IE, after the dialog closes I checked the flash element style and I saw that visibility=visible, but still the flash is still hidden!
Anyone know how to fix this?
Thanks!
Roei
UPDATE: Just for clarify: it works when using wmode is transparent, opaque and window. Just when using "direct" it does not re-appear...

Open Mail.app on IPhone from webpage that's INSIDE an app

our app loads profile pages from our website INSIDE the app. They have been optimized for iPhone css, but they are still an html page. Our mailto link isnt working as expected.
When clicked, nothing happens. However, when clicked and held (tap and hold), the menu slides up with "new message", "create new contact", "copy", etc.
How should this be formatted to get the Mail.app to automatically launch?
<a class="action_bubble" target="_blank" rel="external" href="mailto:bob#bob.com">Send Email</a>
The "call" link works as expected.
<a class="action_bubble" href="tel:1234567890">Call</a>
So, not sure what to do with this...
Here is a project on GitHub that addresses your issue. Basically, when you use a UIWebView controller, you need to decide how to manage the links using the delegate handler for UIWebView. In Interface Builder you can have it automatically recognize phone numbers which is probably why your phone numbers work and it will recognize http links as default behavior. However, mailto and some of the other special href options will need to be handled manually.
make sure "Detection" property is set for your UIWebView like "Phone","Address". you can set it from your IB.
or from code
self.webView.dataDetectorTypes = UIDataDetectorTypeAll;
Could it be, that you have just tried within the simulator? The simulator does not have a mail app, so it couldn't be opened. Try on a device. I think your code actually works.
I've just tested on a device: your code works.
A little late to the party but I've found out the following:
iOS has some weird ways to deal with web content
DON'T encapsulate your email address within an A tag, just put it there as plain text
Make sure that in your storyboard (if using one) the webView has the Addresses property checked and you're done ... same goes for phone numbers

Launching Safari in-app?

Is it possible to Launch Safari without having the app close? Just like the in-app email compose window.
I'm aware of how to display a webpage in UIWebView. I'd like to use a full web browser, i.e. Safari.
You can use a UIWebView to display web content in your app.
You can create a UIWebView with the URL to display. It will follow any links that the user touches, but that won't give you the address bar, search, navigation buttons, bookmarks or the page (tab) control. Those you'll have to add yourself, but odds are you don't want all of that. (Do you really need Google searches in your app?)
Creating a controller to manage a UIWebView and as much or as little navigation as you need is pretty easy. With a little planning, your custom controller class will also a good thing to keep in your library for the next app.
No you can not make use of the full Safari from within your own application. Your application must terminate for Safari to open.
In iPhone OS 2.0 you also had to terminate in order to send e-mails, so some chance exists that Apple couls open up Safari in the same way for iPhone OS 4.0. Make sure to request it at http://bugreport.apple.com if you are eager.
The second best option currently available is to roll your own "Browser view controller" using UIWebView. Let it have back, forward, stop/reload buttons, and an extra button for opening in Safari if the user is not content. This is how many of the greatest apps our there, like Tweetie, does it.