Showing posts with label mobile web. Show all posts
Showing posts with label mobile web. Show all posts

Thursday, August 31, 2017

Javascript touch events

Javascript has the following touch events:
  • touchstart
  • touchmove
  • touchend
  • touchenter
  • touchleave
  • touchcancel
We usually use the following code snippet to detect touch event support

if ('ontouchstart' in window) {
  /* browser with Touch Events
     running on touch-capable device */
}

if (('ontouchstart' in window) ||
     (navigator.maxTouchPoints > 0) ||
     (navigator.msMaxTouchPoints > 0)) {
      /* browser with either Touch Events or Pointer Events (from Microsoft, outdated)
         running on touch-capable device */
}

To support both touch-capable device and desktop mouse input, we can listen to both touch event and click event, something like below

blah.addEventListener('touchend', function(e) {
  /* prevent delay and simulated mouse events */
  e.preventDefault();
  someFunction()
});
blah.addEventListener('click', someFunction);

If we need all touch events handling for Mobile web, suggest to check out some open source libraries, like jQuery Mobile, hammerjs, or jQuery-Touch-Events.

Monday, April 14, 2014

Private browsing will cause QUOTA_EXCEEDED_ERR

If your web site uses local storage, and when user does private browsing your website, it might break. The reason is local storage will not be able to store anything if phone is using private browsing.

Suggest to use Modernizr or below script to do detect. (Try-catch might also work?)

if (!!window.localStorage)
{
    localStorage.setItem(key, val);
};


Wednesday, February 5, 2014

10 Web design trends

http://thenextweb.com/dd/2012/12/30/10-new-web-design-trends-you-can-expect-to-see-in-2013/
  1. More responsive design, please.
  2. Typography will take center stage.
  3. Buh-bye Flash. Hello just about anything else.
  4. Skeuomorphism will show its age.
  5. Large images used for large impact visuals.
  6. Give me (more) white space!
  7. More sharing on social networks.
  8. Calmer color schemes to reappear.
  9. Mobile apps will start to replace mobile browsing.
  10. King content will keep its crown.

http://thenextweb.com/dd/2013/12/29/10-web-design-trends-can-expect-see-2014/
  1. Non-boring typography
  2. Flat design
  3. Large hero areas quickly killing sliders
  4. Heavier focus on mobile
  5. Videos in place of text
  6. Long scrolling sites
  7. Simple color schemes
  8. Simplified content
  9. Dropping the sidebar
  10. Manipulated imagery

Sunday, August 18, 2013

Browser developer tool

Built-in browser developer tool really helps Web development, the all-in-one development environment is getting better and better from desktop browsers.

Chrome: This is my favorite
Firefox: Firebug extension, but I think Firefox 23 built-in tool is cool and promising
Opera: Dragonfly, very clear and easy of use
Safari: Xcode style, hard to use. I seldom use it unless I need debug iOS safari (mobile web remote debug)
IE9: F12. So hard to use, but IE11 is getting much better based on .NET magazine. Hope it will catch up Chrome/Firefox.

Usually the features available from these browser developer tools are similar, and they should Element inspector, Style box model, Resource browser, network activity, Performance, profile, Console etc.

Here are some tips I just learned or I don't use frequently:
  • Don't forget right click in developer tool - the contextmenu has some surprises
  • Debugging Minified JavaScript
  • Emulate a User Agent
  • Checking DOMContentLoad and Load Event
  • Incrementing CSS Values - Simply use the up and down cursor keys to increment/decrement by a unit of 1.
  • console.log() for outputting debug info, will work printf style. like console.log("The flower is %s.", "red")
  • console.assert() can be used to test whether expressions are true or false.
  • console.table() can be used to output data from an array of arrays or a list of objects in a sortable, tabular format.
  • You can automatically create a breakpoint in your code by adding the following line to your JavaScript: debugger;



Friday, June 21, 2013

Turn off autocapitalize on iOS Safari

By default on iOS Safari input text or textarea enables automatic correction and capitalization to streamline mobile typing. However, sometimes, we don't want this, for instance username input text.

We can add autocapitalize="off" autocorrect="off" two attributes to disable this.

When I tested on iOS6.1.4, input email, input passsword don't auto capitalize the first character. Also show correct keyboard.

We can use HTML5 new input types to better control keyboard display
Text: <input type="text" /> <!-- display a standard keyboard -->
Telephone: <input type="tel" /> <!-- display a telephone keypad -->
URL: <input type="url" /> <!-- display a URL keyboard -->
Email: <input type="email" /> <!-- display an email keyboard -->
Zip Code: <input type="text" pattern="[0-9]*" /> <!-- display a numeric keyboard -->

For details, check out https://developer.apple.com/library/safari/#codinghowtos/Mobile/UserExperience/_index.html

Wednesday, June 19, 2013

Build your first Mobile App with HTML5, jQuery, PhoneGap & APIs

Here are the key takeaways from this 1-day free event sponsored by apigee.com.

jQuery Mobile
Check out http://jquerymobile.com/ for details. It is evolving fast, and it is 1.3.x version now. jQuery Mobile is not jQuery mobile version, it is more like jQuery UI mobile version (but not exactly). When we use jQuery Mobile, we usually needs jQuery and jQuery mobile CSS to get things work.

Other mobile web framework and libraries?
http://www.markus-falk.com/mobile-frameworks-comparison-chart/

Mobile Prototyping Tool
http://www.codiqa.com (Recommended in jQuery Mobile website, and apigee team uses it too)
http://www.mobjectify.com/
http://tiggzi.com/home

PhoneGap/Cordova
Port HTML5/CSS3/Javascript based Web app to Native app. It is more like a bridge.
http://phonegap.com/
http://docs.phonegap.com/en/2.5.0/index.html
https://build.phonegap.com/ - Adobe Cloud build service

PhoneGap Alternatives
https://trigger.io/
http://www.appcelerator.com/
http://www.sencha.com/

More about HTML5
http://diveintohtml5.info
http://www.whatwg.org/specs/web-apps/current-work/multipage/index.html

Topics we covered in this event
Prototyping using codiqa
jQuery Mobile
jQuery
PhoneGap
Android developer tool (ADT)
Xcode and simulators
REST APIs (http://zh.wikipedia.org/zh/REST)
apigee API service
Geolocation
Security (sandbox)

Topics we didn't cover in this event
Push notifications
File Storage
Social Graph
Local capabilities
3rd party integration
Legacy integration
code execution

Bonus
Python built-in HTTP server
You can quickly launch a webserver to test mobile web if you have Python installed
python -m SimpleHTTPServer 8080

Companies mentioned in this event
http://www.crunchbase.com/company/socialtagg
http://www.crunchbase.com/company/zoosk
http://www.crunchbase.com/company/eventbrite
http://www.crunchbase.com/company/bitly-2

Here are my thoughts
Why Mobile Web?
- Write once run every device?
- One stack fits all?
- Better upgrade options (fast release cycles)?

Why not Mobile Web?
- Performance?
- HTML5 API limitation?
- Native User Experience?
- Offline limitation?

Native or Web or Hybrid app?
- It depends

Tuesday, August 21, 2012

Debug Mobile Web

Recently I start to develop mobile web, so summarize the debug methods I have explored. Apart from traditional annoying alert and verbose console.log, on desktop I prefer to Chrome developer tool (cmd+shift+I) which is so developer friendly to debug web site. (Safari has developer tool, Firefox has firebug, Opera has dragonfly, IE has F9). Fortunately on mobile web, we also can get similar tools and methodologies to help mobile web development.

Weinre
http://people.apache.org/~pmuellr/weinre-docs/latest/Home.html
It's a debugger for web pages, like FireBug (for FireFox) and Web Inspector (for WebKit-based browsers), except it's designed to work remotely, and in particular, to allow you debug web pages on a mobile device such as a phone.

It has debug server, debug client and debug target.
Adobe® Shadow
http://labs.adobe.com/technologies/shadow/
Shadow is a new inspection and preview tool that allows front-end web developers and designers to work faster and more efficiently by streamlining the preview process, making it easier to customize websites for mobile devices.

As Flash is dropped in iOS, it seems that Adobe is putting more effort to HTML5 and mobile web now (There is a free upcoming event Create the web tour in San Francisco, Sept 2012), and Adobe is creating many good resources and tools for the prominent Web.

iWebInspector
http://www.iwebinspector.com
iWebInspector is a free tool to debug, profile and inspect web applications running on iOS Simulator (iPhone or iPad). @firt is a true expert in Mobile Web, I had his 'Programming the Mobile Web' book with his signature from last year's Velocity conference at Santa Clara. He also created the excellent http://mobilehtml5.org/

Chrome
Chrome settings - Override User Agent/Override device metrics
Safari
Enable Safari's developer tools, then set Safari's UserAgent to Safari iOS

Bookmarklets
I know there are a bunch of bookmarklets to help mobile Web debug, but I have not explored them yet, will update this post when I get chance to try them out.