Javascript click or tts - javascript

i'm trying to make a web aplication than can read text automatically,i have this code:
function hablalo()
{
var palabra = new SpeechSynthesisUtterance('Casilla 6 turno E18');
palabra.lang = "es"
speechSynthesis.speak(palabra);
}
$('#perez').trigger($.Event( "click", { originalEvent: true } ));
and so i have a button with the event that call hablalo.
The problem is that when i try to make this, the result is:
(index):20 [Deprecation] speechSynthesis.speak() without user activation is no longer allowed since M71, around December 2018. See https://www.chromestatus.com/feature/5687444770914304 for more details
I would like a way to simulate a click in chrome or another way to make tts, thanks you. :)
--EDITED
If you know a library that i can use for autoplay tts at load of a webpage, is fine

So i solved my problem with this, summary i modify the laucher-flags of chrome in the client's pc adding --autoplay-policy=no-user-gesture-required at the end of route in propertiesof the launcher.
It seems like is imposible to make from code, but this solution is a resignation way.

Related

Unity js script not working

I have recently taken an interest into unity, and as I guide a chose a playlist from youtube. I have installed the
Unity 5.6.4
16 Oct, 2017
version as well.
Now, I encounter an error when I try to add a script to an object.
In the tutorial:
here
, this happens from 11:40 to 13:40.
Basically, as a summary, he is writing a script in js and then attaches it to an object. Now, I have followed the exact steps as him, but it does not work for me.
I write the same script as him, in JS:
then add the script to the object. But then, on the object, I should get a target option, like he does:
However, I don't get this option on my object:
The error I get in the console is this:
Assets/Scripts/PickUp.js(1,386): BCE0044: unexpected char: 0xFEFF.
And this is the actual script:
var target : Transform;
function Update () { }
function OnMouseDown ()
{
this.transform.position = target.position;
this.transform.parent = GameObject.Find("FPSController").transform;
this.transform.parent = GameObject.Find("FirstPersonCharacter").transform;
}
function OnMouseUp ()
{
this.transform.parent = GameObject.Find ("FPSController").transform;
this.transform.parent = null;
}
Now, I've heard that it is not the most efficient, but at this point, I don't really care about that, I just want it to work.
Try to save your script using UTF8 - no BOM (ByteOrderMark). If that does not help, save as Ansi and try that - or read up what unity wants :)
Unity3d Issue Tracker: textassets-encoding-prefab-with-utf8-bom-encryption-is-corrupted it might be related.
This UTF-8 as default in Unity3D new script? was not solved unfortunately.

Tracking link in different browsers

I use adobe analytics and try to track links using this:
$(document).on('click', 'a', function() {
s.tl(this, 'e', 'link', null, 'navigate');
return false;
});
or
$("a").click(function() {
s.tl(this, 'e', 'link', null, 'navigate');
return false;
});
and when I tested it and click in a link in Chrome I receive for the first the status page canceled and using the second option in chrome everything works fine but in Firefox I receive status 0 GET (NS_BINDING_ABORTED).
Is there any workaround which could run without problem in all browsers or should I fix anything to the previous?
From here is the example I use using the second box as example
I found this solution:
https://marketing.adobe.com/developer/es/forum/general-topic-forum/custom-link-tracking-capturing-issue
Which proposes this as a work around:
<script language="javascript">
function pejTracking(linkname,url) {
var s=s_gi('myprodsuite');
s.tl(this,'o',linkname,null,navigate(url));
}
function navigate(url) {
window.location=url;
}
</script>
This really works!
Is it possible to make it to work with the JQuery document or a onclick function as I have at the start of my post and there is any need to have the onclick in every link?
This is common, and (probably) isn't a problem.
This error occurs because the link tracking image request is designed to let the browser proceed to the next page before waiting for a response from the Adobe data collection servers.
Adobe Reference: NS_Binding_Aborted in Packet Monitors
Update:
You commented:
Yes I have seen this but is it possible to fix it?
You are asking to "fix" this as if it's something that is broken.. my point is that it's not broken.
But if you insist on wanting to make sure this doesn't show up, you will need to do the solution you already posted in your question.
The jQuery equivalent would be to make use of event.preventDefault() and then update window.location after the s.tl call (in navigate callback) same as the non-jQuery solution.
You also asked:
And what about chrome?
What about it? This isn't browser-specific. It has to do with timing. Try it enough times in Chrome and you should see that NS_Binding_Aborted error in Chrome, too. Maybe. Depends on connection speed, current CPU resources, internet traffic in general, how the stars are aligned, etc. - you know, all the things that make requests and response happen later rather than sooner.

Phonegap (Android) - database changeVersion not functioning

If I take a database object (db) and open it with the command
var db = window.openDatabase("phr", "", "Cognovant PHR", 25000000);
// This should open whatever database is created, otherwise spawn one with a blank
// version number ("")
and then later do:
db.changeVersion(db.version, "2"); // Update database to version 2
console.log(db.version); //Should return "2", instead returns previous version of database
This code, line-for-line works flawlessly (almost better than I had hoped) on iOS, but constantly fails to change the database version on Android.
If there's some better way to do this, or some alternative way that needs done on Android, I would be greatly appreciative of the information.
This is actually pretty simple to solve.
Simply change the 2 argument version of db.changeVersion to the 3 argument version. Example:
db.changeVersion(db.version, "2", function () {console.log("foobar")});
And it will work.
This problem also occurs in Android 2.2.
09-28 07:15:14.954: E/Web Console(280): TYPE_MISMATCH_ERR: DOM Exception 17: The type of an object was incompatible with the expected type of the parameter associated to the object. at file:///android_asset/www/devbar/03%20db.js:158
The only solution I see is to workaround with my own version management.
Please go through below link, describes the way to implement the database Version control.
http://developer.apple.com/library/safari/#documentation/iphone/conceptual/safarijsdatabaseguide/UsingtheJavascriptDatabase/UsingtheJavascriptDatabase.html
i am able to do success operation with all 2.3.x devices, but with 4.x.x android device getting issue like 'unable to call method changeVersion' and saying method is undefined.
for time being i am using code as below,
if (db.changeVersion) {
db.changeVersion(oldVer, curVer, upgradeTableStructure, errorHandler, successDataHandler);
} else {
createTableStructure(db);//If Not exist for first time for 4.x.y devices
console.log('version changes not possible in this browser version.');
}
but this is not the right solution for the Current Problem, please suggest some solution.

How to code firefox extension which run javascript code in the page's context like firebug does

I know that for safety reasons that this is not easy to achieve, however there would be a way to do so as firebug does...
Please help, would like to invoke some script in the page's context to achieve some effect...
Basically, I would like to achieve two functionality:
1. add jQuery to any web page automatically if not already exist.
2. when open certain address, call a method of that page to auto notify the server. (an ajax functionality of the page)
I have tried to inject on the body, no luck.
tried to get the window object, which however do not have access to call the function.
Will try to change the location to something like: javascript:alert('test inject');
Many thx.
OK, after reading some official documentation and the GreaseMonkey's source, I get the following method which basically works for me.
Hope it will save sb's hour:
var appcontent = document.getElementById("appcontent"); // browser
if (appcontent) {
appcontent.addEventListener("DOMContentLoaded", function (evnt) {
var doc = evnt.originalTarget;
var win = doc.defaultView;
var unsafeWin = win.wrappedJSObject;
// vote.up is the function on the page's context
// which is take from this site as example
unsafeWin.vote.up(...);
}, true);
}
}
Greasemonkey does that. If you are developing your own extension with similar functionality, you can use Components.utils.evalInSandbox.

"Stack overflow in line 0" on Internet Explorer

I realise this is not the ideal place to ask about this in terms of searchability, but I've got a page whose JavaScript code throws "Stack overflow in line 0" errors when I look at it in Internet Explorer.
The problem is quite clearly not in line 0, but somewhere in the list of stuff that I'm writing to the document. Everything works fine in Firefox, so I don't have the delights of Firebug and friends to assist in troubleshooting.
Are there any standard causes for this? I'm guessing this is probably an Internet Explorer 7 bug or something quite obscure, and my Google-fu is bringing me little joy currently. I can find lots of people who have run into this before, but I can't seem to find how they solved it.
I ran into this problem recently and wrote up a post about the particular case in our code that was causing this problem.
http://cappuccino.org/discuss/2010/03/01/internet-explorer-global-variables-and-stack-overflows/
The quick summary is: recursion that passes through the host global object is limited to a stack depth of 13. In other words, if the reference your function call is using (not necessarily the function itself) was defined with some form window.foo = function, then recursing through foo is limited to a depth of 13.
Aha!
I had an OnError() event in some code that was setting the image source to a default image path if it wasn't found. Of course, if the default image path wasn't found it would trigger the error handler...
For people who have a similar problem but not the same, I guess the cause of this is most likely to be either an unterminated loop, an event handler that triggers itself or something similar that throws the JavaScript engine into a spin.
You can turn off the "Disable Script Debugging" option inside of Internet Explorer and start debugging with Visual Studio if you happen to have that around.
I've found that it is one of few ways to diagnose some of those IE specific issues.
I had this problem, and I solved it. There was an attribute in the <%# Page tag named MaintainScrollPositionOnPostback and after removing it, the error disapeared.
I added it before to prevent scrolling after each postback.
If you came here because you had the problem inside your selenium tests:
IE doesn't like By.id("xyz"). Use By.name, xpath, or whatever instead.
Also having smartNavigation="true" causes this"
I set up a default project and found out the following:
The problem is the combination of smartNavigation and maintainScrollPositionOnPostBack. The error only occurs when both are set to true.
In my case, the error was produced by:
<pages smartNavigation="true" maintainScrollPositionOnPostBack="true" />
Any other combination works fine.
Can anybody confirm this?
Internet Options
Tools
Internet options
Advanced
Navigation section
Click > Disable script debugging
display a notification about every script error
sign in
You will smile !
My was "at line 1" instead but...
I got this problem when using jQuery's .clone method. I replaced these by using making jQuery objects from the html string: $($(selector).html()).
I have reproduced the same error on IE8. One of the text boxes has some event handlers to replace not valid data.
$('.numbersonly').on("keyup input propertychange", function () {
//code
});
The error message was shown on entering data to this text box. We removed event "propertychange" from the code above and now it works correctly.
P.S. maybe it will help somebody
I don't know what to tell you, but the same problem occured with jQuery table sorting and SEARCH.
When there is nothing left in the table, where you are searching a string for example, you get this error too. Even in Google Analytics this error occurs often.
In my case I had two functions a() and b(). First was calling second and second was calling first one:
var i = 0;
function a() { b(); }
function b() {
i++;
if (i < 30) {
a();
}
}
a();
I resolved this using setTimeout:
var i = 0;
function a() { b(); }
function b() {
i++;
if (i < 30) {
setTimeout( function() {
a();
}, 0);
}
}
a();
This is problem with Java and Flash Player. Install the latest Java and Flash Player, and the problem will be resolved. If not, then install Mozilla Firefox, it will auto install the updates required.

Categories