I am having an issue where the Screen Reader is not reading the text that changes within aria-live section in FireFox.
This is a simple example for a page where in chrome the Screen Reader reads the changes as they come in and in FireFox it does not:
<div aria-live="assertive" id="moo">
</div>
<script>
let i = 0;
setInterval(() => {
document.getElementById('moo').innerText = 'moo' + i++
}, 2000)
</script>
Am I doing something wrong? Is there another way to announce changes when they come in besides for aria-live that people use with Firefox?
I tested on Mac-Firefox-VoiceOver (it works on Mac-Chrome-VoiceOver)
Current firefox version: 83.0 (64-bit)
Firefox Nightly version:85.0a1 (2020-11-29) (64-bit)
In the latest Nightly version, the combination of aria-live on firefox + voiceOver is fixed! 🎉 Hooray!
Reference:
Firefox/Voiceover: aria-live regions not being announced
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aria-live Demo</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<style>
body {
margin: 1em;
}
button {
margin-top: 1em;
display: block;
}
</style>
</head>
<body>
<h1>Aria-live Demo</h1>
<p>Testing <code>aria-live</code><br><button>Add Content</button><button id="add-more" >Add more content</button></p>
<!-- add aria-live="polite" -->
<div class="target" aria-live="polite" ></div>
<script type="text/html" id="test-content">
<h2>Custom Content</h2>
<p>Hello there! I am content that is going to be plunked into a container via javascript</p>
</script>
<input placeholder="messgae somebody"/>
<script>
$("button").on("click", function(){
$(".target").html($("#test-content").html());
});
$("#add-more").on("click", function(){
$(".target").append("<p>Hello World</p>");
});
$(document).on("keydown", function(e){
// press space to add content
if(e.keyCode === 32) {
$(".target").append("<p>Hello World</p>");
}
});
</script>
</body>
</html>
Related
I have created a webpage using HTML, CSS, JS (Paper.js)
But I want my webpage to be displayed only when opened in desktop sites
if it is opened in any smartphone the a message must appear like open in desktop nothing else must be loaded
because in touch screen devices all functions does not work properly
link to my webpage is -
https://sachinverma53121.github.io/Keypress-Sounds/key-sounds.html
You could use JS to not display the div/tag if the page is less than a certain width
Something like this might do:
<p id="demo">This only shows when the window is more than 500.</p>
<p id="message" style="display: none;">Please use this on a desktop.</p>
<script>
if (window.innerWidth < 500){
document.getElementById("demo").style.display = "none";
document.getElementById("message").style.display = "block";
}
</script>
You could also use CSS
<style>
#message {
display: none;
}
#media (max-width: 500px){
#demo {
display: none;
}
#message {
display: block;
}
}
</style>
<p id="demo">This only shows when the window is more than 500.</p>
<p id="message">Please use this on a desktop.</p>
you can do this in bootstrap like this. The paragraph hides on mobile size if you want to hide it on tablet size too, change the "sm" to "md" to find out how to use it visit this link https://getbootstrap.com/docs/4.2/utilities/display/:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<title>title</title>
</head>
<body>
<div class="d-none d-sm-block">
<p>hide me on mobile</p>
</div>
<div class="d-block d-sm-none">
<p><strong>show me on mobile</strong></p>
</div>
</body>
</html>
add a
<script>
var userAgent;
(function() {
userAgent = navigator.userAgent.toLowerCase();
if (typeof orientation !== 'undefined' || userAgent.indexOf('mobile') >= 0); {
alert('open in desktop');
} else {
document.body.innerHTML = 'your HTML as a string here';
}
})();
</script>
Windows Virtual keyboard is not showing when app is running in touch mode (tablet device/simulator) and I'm manually triggering focus() on input. Instead keyboard shows when tapping anywhere on body (meaning that input is focused). Hoverer when running application as a regular desktop app with mouse input (instead of touch) - everything works well.
So the question is how to avoid such behaviour or at least how to manually display virtual keyboard when input is focused?
I'm using WinJS.4.0 4.0.0.winjs.2015.6.9.
Sample code to replicate the issue:
default.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>App1</title>
<!-- WinJS references -->
<link href="WinJS/css/ui-dark.css" rel="stylesheet" />
<script src="WinJS/js/base.js"></script>
<script src="WinJS/js/ui.js"></script>
<!-- App1 references -->
<link href="/css/default.css" rel="stylesheet" />
</head>
<body class="win-type-body">
<div id="container">
<div id="text-holder">
Input value will be displayed here
</div>
<div id="input-holder">
<form id="form">
<input id="input" value="" type="number"></input>
</form>
</div>
</div>
<script src="/js/default.js"></script>
</body>
</html>
default.js
(function () {
var input = document.getElementById('input');
var form = document.getElementById('form');
var textHolder = document.getElementById('text-holder');
form.addEventListener('submit', function (e) {
e && e.preventDefault();
textHolder.innerText = input.value;
input.value = "";
input.blur();
});
textHolder.addEventListener('click', function (e) {
console.log(e);
input.focus();
});
})();
default.css:
body {
background-color: #fff;
}
#container {
width: 100%;
height: 100%;
}
#text-holder {
width: 200px;
height: 50px;
background-color: #191A15;
color: #fff;
}
Visual guidance:
Step 1:
Step 2:
Thanks for your interest, hope this problem is solvable.
It is a known OS issue with winjs/uwp app running on a W10 (build 10.240). It has been fixed with W10 TH2 (build 10.586) as mentionned in the following MSDN thread
I am using ngPaste on a contentEditable div instead of input type text. However, I am unable to fetch the pasted content in the way mention in this link. I am always getting undefined in my handler for ngPaste. Here's the code:
HTML:
<div contentEditable="true" ng-paste="stripHtml($event.clipboardData.getData('text/plain'))">
</div
>
JS:
scope.stripHtml = function(content) {
console.log(content); //this is always undefined
}
What am I doing wrong? How can I fetch the pasted content?
The Below Code (Modified from Sergey's) Worked in Windows platform, Firefox 43.0.4, Chrome 47.0.2526.111 m but NOT in IE 11.0.9.
<!DOCTYPE html>
<html>
<head>
<style>
.editable {
background: white;
height: 55px;
border: 2px solid blue;
width: 55%;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script>
<script>
var myApp = angular.module('myApp', []);
myApp.controller('sampleController', function($scope) {
$scope.stripHtml = function(content) {
alert(content);
console.log(content);
};
});
</script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>AngularJS ng-paste within ContentEditable Div</title>
</head>
<body ng-app="myApp">
<div ng-controller="sampleController">
<div class="editable" contentEditable="true" ng-paste="stripHtml($event.clipboardData.getData('text/plain'))"></div>
</div>
</body>
</html>
I created a very basic page to illustrate this...
<!DOCTYPE html>
<html> <!-- manifest="cache.manifest"-->
<head>
<title>FireFox Touch TEST</title>
<style>
body {width:100%; height:100%; background-color:green;}
div.testdiv {top:0px; left:0px; width:1in; height:1in; background-color:blue;}
</style>
</head>
<body class="body">
<div id="test" class="testdiv">Touch here</div>
<script type="text/javascript">
function tStart(event)
{
alert("Touched");
}
divid = document.getElementById("test");
divid.addEventListener('touchstart', function(){tStart(event)},false);
</script>
</body>
</html>
I seem to be either doing something fundamentally wrong or there is a problem with mobile firefox 24 on android 4.2.2
Any ideas...
Try like this:
As there is no such a variable in tStart() that calls event, the browser looks if there is an event defined in the global object. In JavaScript, the global object is called window
function tStart(event)
{
alert("Touched");
}
divid = document.getElementById("test");
divid.addEventListener('touchstart', function(){tStart(window.event)},false);
I am building a phonegap app using javacsript and jquery.I wrote this piece of code to swipe images.
$('#fullscreen').swipeleft(function () {
//Show next image
showNext();
alert('Left');
});
function showNext() {
$("#fullscreen").attr('src', "images/next.png");
}
But when I swipe, the image doesn't change and I get the error "09-13 14:49:21.188: W/webview(20238): Miss a drag as we are waiting for WebCore's response for touch down."
After browsing through some forums I added the following code.
var fullScr = document.getElementById("fullscreen");
fullScr.addEventListener( "touchstart", function(e){ onStart(e); }, false );
function onStart ( touchEvent ) {
if( navigator.userAgent.match(/Android/i) ) {
touchEvent.preventDefault();
}
}
But it still doesn't work.Although when I change my screen orientation from portrait to landscape, the image changes.
What is it that happens when I change the orientation and how could I get it working in the same orientation (portrait/landscape) please?
Thanks in advance.
Well it worked for me :S... I used version 1.5.0 of Cordova and run the app on Android simulator 4.0.3. Could you try the following example?
HTML content:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<!-- BASIC INCLUDES - TO BE MODIFIED ACCORDING TO YOUR CONVENIENCE -->
<link rel="stylesheet" href="./css/jquery.structure-1.1.0.min.css" />
<link rel="stylesheet" href="./css/jquery.mobile-1.1.0.min.css" />
<script type="text/javascript" charset="utf-8" src="cordova-1.5.0.js"></script>
<script type="text/javascript" src="./js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="./js/jquery.mobile-1.1.0.min.js"></script>
<!-- END - BASIC INCLUDES -->
<script type="text/javascript" charset="utf-8">
$(function() {
$('#fullscreen').swipeleft(function () {
//Show next image
showNext();
});
function showNext() {
$("#fullscreen").attr('src', "./images/next.png");
}
});
</script>
</head>
<body>
<div data-role="page">
<div data-role="content">
<img id="fullscreen" src="./images/previous.png"></img>
</div>
</div>
</body>
</html>
NB: Make sure of the following things:
Modify the source of the "basic includes" of the code to your convenience (source of the CSS / JS files of jQuery / jQuery Mobile)
Change the source of the version of cordova if yours is not 1.5.0
Hope this will work for you too. Anyway, let me know about your result.