Does javascript work on mobile phones? - javascript

Does javascript work on mobile phones?

Which mobile phones?
There's some pretty good information on this site:
http://www.quirksmode.org/m/table.html

depends on the browser

Some. Do you have a specific model in mind or just in general?

Depends on what mobile phones and to what extent you need support.
Smart phones pretty much all include support for JavaScript. How well they support them is another story.
You can see a lot of what mobile devices support here: http://www.quirksmode.org/m/table.html

In general I would assume that javascript isn't there, as older cellphone models may not support javascript, but, if you use unobtrusive javascript and graceful degradation, then it won't really matter, as your page will function in some known way on any device, as long as it is formatting itself properly.
So, if you want to have it work on all mobile phones, then start with not needing javascript, then add in the javascript as an enhancement.

Bare in mind as well that their are different versions of JavaScript supported by different phones and different browsers, even if JavaScript is available.

http://www.skyfire.com/ if you can get that browser on it then you can get javascript! Awesome browser and quite portable...
Works on Symbian (Nokia Phones use it) and Windows Mobile.

I think javascript is totally browser dependent. Symbian mobile surely can run javascript. Smart phones are much smarter to handle javascript.

Related

making the difference between pc to mobile

I have a website with a lot of javascript code in it.
Now of curse the CSS was edited so the website would look good on mobile too.
About js what should I do? Should I just leave everything on the mouse events and keyboard events or should I detect if a mobile device is using the website and then make another file of js just for mobile with the same actions, maybe in the sane file?
I would appreciate any help with that.
For js it will work hopefully on mobile devices just like it did on your Desktop, you just need to ask yourself if you're using new js code that may no be supported by older browser like for example if you are using promises to make http request then maybe some old phones having old browser will not behave properly (to check if what you are using is supported check this out https://caniuse.com)
Let's say you're using something that is not supported, you can (most of the time) use a polyfill from the internet to make sure the code you write is always working fine.

Alternative to IndexedDB in not supported browsers? Safari/iOS Saf-Chrome

I have a working sample with IndexedDB that works perfect for my Desktop Chrome. Nevertheless, my main aim is to develop for iOS devices (Chrome-Safari) and this API isn't available there yet.
What should I do?
I have seen this Polyfill: http://nparashuram.com/IndexedDBShim/. But, I tested it with my iPod Touch 5th Gen and somehow the 19th test doesn't work...
Should I use WebSQL which was deprecated?
I liked the idea of the Polyfill but that it not working for me...
Are there any plans to support IndexedDB in the future for all the non-supported browsers?
Thanks!
Here is another similar polyfill you can try, but in my (albeit limited) experience, both polyfills are buggy/incomplete. They both also have many open issues on GitHub of people reporting problems. And when I tested one of them (I forget which one) it was significantly slower than native IndexedDB.
Maybe it's possible to create a decent polyfill, but the current ones don't seem to be doing the job.
Should I use WebSQL which was deprecated?
The problem with WebSQL is that it's never going to be supported in IE or Firefox. You could probably get away with WebSQL if you're only targeting mobile browsers, at least until Firefox OS or Windows Phone grabs significant market share.
Are there any plans to support IndexedDB in the future for all the non-supported browsers?
Let's be clear. You're asking about Apple, since everyone else supports IndexedDB in their latest browser (iOS Chrome uses Apple's rendering engine because Apple won't let them do anything else).
Not only does Apple not support IndexedDB, they haven't publicly said anything about it (as far as I can tell... and I have done a fair amount of searching). Which seems pretty weird. So as best I can tell, nobody has any idea if Apple ever plans to support IndexedDB. The conspiracy theorist in me thinks maybe they're trying to sabotage HTML5 apps to force people to write native apps, but that's purely speculation.
In total, this leaves us developers in a pretty shitty situation. There is no good cross-platform solution. I recommend you complain to Apple about it. That's what I've done, and I've asked my users who want to use my IndexedDB-based app on iOS to do the same. Still no word from Apple.
UPDATE - Indexeddb is now supported in iOS 8 as stated in WWDC 2014 - but unfortunately it's broken pretty badly.
Looks like IndexedDB is not working as web app (pinned to the home screen).
Works inside Safari.
IndexedDB was never be made to be directly used by developers. It is more like an API that can be used to build a "real" database on top of it.
Nowadays there are many alternatives that you could use instead.
NeDB used heavily, but deprecated
PouchDB
RxDB
If you still need to use IndexedDB, at least I would recommend to use a wrapper like dexie.js which at least makes it easier.

Can I reasonably assume mobile browsers with JavaScript also support jQuery?

I realise that this question may be almost impossible to answer definitively, but:
Is it reasonable to assume that mobile browser with JavaScript can also cope with jQuery? We're talking relatively basic jQuery such as click events and Ajax.
I'm writing a mobile HTML app. It involves slippy maps so anyone who wants to use it has to have JavaScript.
I'd much prefer to use jQuery for the rest of the coding if possible, but can I reasonably say to the client "any phone with JavaScript should support basic jQuery"?
I know about jQuery mobile, but I'm specifically talking about phones that aren't advanced enough to handle jQuery mobile, but do have JavaScript.
Thanks!
Yes.
jQuery is not a language. It is a library written in JavaScript, and therefore if you can run JavaScript reasonably well, you should be able to run jQuery without any problems.
With that being said, nothing compares to actual testing. Periodically check that your code works across multiple platforms (not only on different phones, but different web browsers as well).
javascript is javascript. You can always use jQuery.support to detect features. You should test on the browsers you want to support anyway.
The answer is simple: yes.
JQuery, and especially its most basic features, is designed to be cross browser. If the mobile browser has reasonable javascript support, JQuery should not be an issue.
For fallbacks on features you aren't sure whether or not are supported, you can use jquery.Support or Modernizr
It should run okay on most... don't expect much from explorer pocket.
Although jQuery functions across these
browsers, IRL many of the cool
effects that jQuery makes simple won't
be seen on a mobile browser, because
the interface is so different. There
is (almost) no concept of mousedown,
mouseup, or hover; click and focus
behave differently, screensize is
different vs effective window size,
animations are slow, etc. The
challenge in mobile browsers is mostly
in the interface design. The main
advantage IMO is AJAX-loaded content,
for speed and low data/bandwidth
usage.
In short: yes.
HOWEVER, if you're only doing Ajax and other little things, you'll see a significant speed gain just using vanilla JS. But I do realize this can be somewhat of a pain. There are lighter-weight packages out there, like xui.
Honestly, I'd consider programming separate sites for mobile Safari (iOS and Android), and other lower-powered devices that don't run WebKit.
To iterate again: jQuery.mobile is NOT a replacement for jQuery, but rather framework that builds on jQuery, much like jQuery-ui does. This would be an even larger footprint and bootstrap time.
You can check http://jquerymobile.com/ - maybe it is what you should use on your pages instead of "regular" jquery.
Yes but you will better off using jQuery Mobile in case you are developing for mobile devices. It's optimized for them.
Check out jQuery mobile, as well as this very informative slideshare which describes the scope and difficulty of the problem you're facing.

Should we use server-side solution in place of javascript as much as possible for multi-device viewing?

By multi-device viewing, I mean that it will be seen on both desktop computers and mobile.
Will mobile user get better performance and usability without JavaScript? Would it be good if we make site with pure CSS and server side programming for mobile? Opera Mini, iPhone safari, blackberry browser, Windows mobile browser, whatever?
Graceful degradation takes time to implement. So if we go with pure CSS for fancy things and server side solution for dynamic things , is it a better idea?
Although there is a good answer here, first think on pure CSS solution or server side solution if needed is a good idea I think.
The phone/browser combos you've mentioned all have fully functional javascript interpreters. Any modern smartphone is going to be capable of most of what you can throw at it. If you're doing excessive processing client side in javascript, you're probably doing it wrong already.
Write code that degrades gracefully, and if you're doing it right, your site should work properly without javascript by simply adhering to the standards. Start with a design that works without scripting, and then layer in the niceties. In most cases, this produces a cleaner, more maintainable application.
I don't know a ton about designing sites for mobile phones, but what you're saying sounds logical. JavaScript is run client-side, and since mobile devices have rather limited processors, it makes sense to do as much work as possible on the server.
I like to do it server side. You can use WURFL to get database of existing mobile devices and when you detect one you server a customized view for mobile devices.

Using JavaScript in mobile web application

I need to use JavaScript in a form for mobile web application.
I need some information about it, related to browser compatibility as well as way to use JavaScript in mobile web applications (syntax).
It's a nightmare. It's like working with web-browsers in the 90's but with the manager expectations of tomorrow.
I strongly recommend you determine your target platforms in terms of regions, software, and actual hardware since the market is much more fragmented than the web and a large number of mobile devices have issues with CSS, JS and even XHTML ranging from painful to not-on-this-platform.
The good news is that android and iphone are pushing the field rapidly. The bad news is that makes a lot of the sources you'll google badly out-of-date.
Some references:
http://www.w3.org/TR/mobileOK-basic10-tests/#test_objects_or_script
http://mobiforge.com/developing/story/getting-started-with-mobile-ajax
http://mobiforge.com/
Especially that last one :)
The reality have changed since this question was asked. Modern smartphones support browsers, that are compatibile with their desktop big brothers, with same JavaScript support. However, still there are differences how application is displayed and how it is operated, you can't rely on drag-and-drop, there are some rendering differences, f.g. in GWT-Ext Showcase on Opera Mobile tab close buttons are not rendered. So you should not rely on modern JavaScript 'magic framework' such as Ext.
Agree with the "it's a nightmare" comment.
Some tips:
For simple scripts, go right back to JavaScript basics - no JS frameworks - think document.getElementById();
Always make sure your JavaScript is valid. If you have an object, make sure you have commas and semi-colons in the right place. An easy way to check this is in Internet Explorer - check in the bottom left for the valid or invalid JavaScript icon.
Make sure your Javascript is XML valid - Blackberry's won't like it if it's not.
For something more complex, check out jquery mobile: http://jquerymobile.com/ - some nice stuff in there.
I would recommend you to use new framework for mobile web applications Sencha http://www.sencha.com/
This framework supports wide range of mobile platforms like Adroid, iPhone and others...
Good luck,
Yevgeniy V.
Softjourn Inc.
Software developer.
Another good solution to target multiple devices (IPhone, Android, BlackBerry, Bada ...) and take advantage of innovative components is to use the JavaScript Toolkit Wink.
Khushi,
I have just founded a framework called PhoneGap, you build your whole app using javascript, html5 and css. You even can play with device native features.
Take a look at for more information http://www.phonegap.com/about .
Totally agree with annakata,
It is a minefield trying to work with JavaScript on a mobile phone in fact we(I work for a mobile agency) tend to recommend to clients that you don't use JavaScript in your mobile pages.
If you have to use JavaScript then look into
WURLF - http://wurfl.sourceforge.net/
MobiForge - http://mobiforge.com/
MobileElements - http://www.mobileelements.com/
And I would recommend creating an iPhone only site that has all the cool functionality and then a plain site for everyone else so that it works well for them.
Also remember you can use device anywhere for testing on multiple phones as well
You may know Patrick H. Lauke, who wrotes the quirksmode blog. He started to work with mobile phones in the not so recent past.
He is publishing his work on the same website in the same wonderful quality of his.
Browsers in the new mobile phones are getting better, that's true, but unfortunately even crazier bugs are popping up.
Not all are javascript related, but you could check his mobile pages at:
http://www.quirksmode.org/mobile/

Categories

Resources