Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make sure touch events are enabled in Firefox desktop browser?

I used a simple test on a windows 7 desktop with touch capabilities. For simplicity it was something like this:

temp_div.addEventListener('touchstart', function(e){ /*confirm */ }, false)
temp_div.addEventListener('pointerdown', function(e){ /*confirm */ }, false)
temp_div.addEventListener('mousedown', function(e){ /*confirm */ }, false)

In chrome, the 'touchstart' was confirmed. In IE, the 'pointerdown' was confirmed. In Firefox, the 'mousedown' was confirmed.

After troubleshooting, I ultimately had to go to 'about:config' in Firefox and change the 'dom.w3c_touch_events.enabled' value from 0 to 1. This caused the 'touchstart' to be confirmed in Firefox.

My questions are these:

Shouldn't this have already been enabled on a touch-capable machine? IE and Chrome were configured properly and Firefox was not. (This was a brand new download of Firefox 31).

Is there anyway to enable touch events remotely in a case like this so that Firefox behaves similarly to the other browsers?

Thanks

like image 378
William Smith Avatar asked Jul 29 '14 20:07

William Smith


People also ask

How do I enable touch scrolling in Firefox?

You can also open about:config in firefox to set dom. w3c_touch_events. enabled=1 (default is 2).

How do I test touch events on my desktop?

Activate the Developer Tools with CMD+ALT+i (OSX) or F12 (Windows). Click the cog icon to open up it's settings. Then switch to the Overrides tab. Make sure Enable is checked and then activate Emulate touch events.

How do I view a mobile site on my desktop Firefox?

Showing the mobile version of websites is a built-in feature in Firefox. In Firefox select Tools -> Web Developer -> Responsive Design Mode and then from the dropdown menu select your device model.


1 Answers

In order to enable touch events in the desktop version of Firefox, type "about:config" into the address bar of the browser, click the "I'll be careful, I promise!" button and scroll down until you find "dom.w3c_touch_events.enabled" ....when you click this item, a dialog box will appear that allows you to change the value of the setting.

disable=(0) enable=(1) auto-detect=(2)

This should be set to "auto-detect" by default, but currently, the desktop version of Firefox is set to "disable" due to some bugginess.

Info about this setting can be found here: https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Touch_events

excerpt:

The dom.w3c_touch_events.enabled tri-state preference can be used to disable (0), enable(1), and auto-detect(2) support for standard touch events; by default, they're on auto-detect(2). After changing the preference, you must restart the browser for the changes to take effect.

Note: As of Gecko 24.0, the touch events support introduced with Gecko 18.0 has been disabled on the desktop version of Firefox, as some popular sites including Google and Twitter are not working properly. Once the bug is fixed, the API will be enabled again.
The mobile versions including Firefox for Android and Firefox OS are not affected by this change. Also, the API has been enabled on the Metro-style version of Firefox for Windows 8.

like image 177
William Smith Avatar answered Nov 09 '22 02:11

William Smith