Im building a app/site using NW.js (known as node-webkit) The docs say that under linux Notifikations onclick event handler dont get fired, and my tests shows that aswell. but when running on windows 7 (x86 bit) the event is not fire'd ether, while it all is running on osx and under chrome + firefox
it's easy to reproduce just run a sample with somthing along the lines of:
var noti = new Notifikation("foo titile");
noti.onclick = function() { console.log("bar") };
I ran into same problem and have been searching for an answer since yesterday night and even though I couldnt find the real answer for the "Why 'onClick()' event handler doesn't work" question, I found a workaround.
First of all, javascript is case sensitive. The appropriate usage of the 'click' event handler is 'onClick'
So the correct format is
//NOTE: I'm not sure if 'Notifikation' works here. Correct use of it is 'Notification'
var noti = new Notifikation("foo titile");
noti.onClick = function() { console.log("bar") };
Now, even though your spelling is correct, onClick event still didn't work for me on nwjs-v0.12.2-win-x64 , Windows 8.1.
What I tried as an alternative is the addEventListener(event, function) method.
In this case your code would be:
var noti = new Notifikation("foo titile");
function clicked() { console.log("bar") };
noti.addEventListener('click',clicked);
I know this question is 2 months old but I just wanted to answer in case someone else would face the same problem.
Related
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.
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.
In my Thunderbird Addon called PasteHyperlink, I have a routine that inserts an html element into the Message Compose Window.
This used to work in Thunderbird, but now I get this js error:
Error: TypeError: thiseditor.insertElementAtSelection is not a function
However, it seems that thiseditor gets defined because it doesn't launch the alert.
Here is the function's code which I've reduced to the basic functionality:
var thiseditor = gMsgCompose.editor;
if (!thiseditor){ alert("Dude, the gMsgCompose.editor is broken") };
let link = thiseditor.document.createElement("a");
link.setAttribute("href", "http://stackoverflow.com");
link.textContent = "Display Text";
thiseditor.insertElementAtSelection(link, false);
MDN has this documentation, but I can't find anything anywhere that talks about why this is broken or what changed under the hood in Thunderbird 45.
Why did this quit working, and what should I do instead?
Well, I think I figured it out. I changed this:
var thiseditor = gMsgCompose.editor;
to this:
var thiseditor = gMsgCompose.editor.QueryInterface(Components.interfaces.nsIHTMLEditor);
Funny thing, it worked the first way for quite a long time. I don't know what changed in Thunderbird, though.
Apparently, this call to window.open is not valid under Internet Explorer. The Javascript code on my site is not running, I would assume it is due to that error.
The line it tells me the error is on, is the call to window.open, apparently an argument is not valid there.
$('.objeto').click(
function() {
var center = 'height=380,width=900,top='+((screen.width - 900)/2)+',left='+((screen.height - 380)/2);
var address = $(this).attr('id');
window.open (address,'Ver articulo', config=center);
}
);
The site runs fine under both Google Chrome, and Firefox.
In IE, you can't have spaces in your second variable (the new window's name).
Try:
window.open (address,'Ver_articulo', config=center);
Also worth re-iterating that IE9 (and possibly below) doesn't like hyphens ('-') in the window name (2nd parameter).
I know one of the comments mentioned this, but it's a bit buried - and it's one tip that just solved an issue for me.
I'm not sure what config is, you just need:
window.open (address,'VerArticulo', center);
Keep in mind though, it looks like your id attribute is invalid to get the effect here, you probably want to use something different, e.g. data-href="urlHere" on the element, if it's not an anchor already.
even thou it's kind a late with answer for OP, but for someone else stumbling across this post it might help:
Had exactly same problem as OP after trying to use "window.open" method. It turns out that Chrome is ok with original href tag with URL in it where IE seems to get confused with that. After removing href from link worked spot on.
CODE SAMPLE:
$(document).ready(function ()
{
$('a[rel^="external"]').each(function ()
{
var externalLink = $(this);
var externalLinkValue = externalLink.attr("href");
externalLink.unbind('click');
externalLink.removeAttr("href");
externalLink.click(function (event)
{
event.preventDefault();
followExtrenalLink = window.open(externalLinkValue,'_blank');
});
externalLink.hover(function ()
{
externalLink.css('cursor', 'pointer');
});
});
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.