I used normal javascript in node - webkit for eg:
var blinkOrder = 20;
var blinkNumber = 12;
var asdf = document.title;
function asd(){
if (blinkNumber >= blinkOrder) {
document.title = ' hi';
blinkNumber = 0;
}
else{
document.title = asdf;
blinkNumber++;
}
setTimeout(asd(),10000);
}
asd();
And I am getting error Like this:
Uncaught node.js Error RangeError: Maximum call stack size exceeded at asd (file:///C:/Users/Humlal/Downloads/Compressed/node-webkit-v0.10.5-win-ia32/index.html:5:13) at asd (file:///C:/Users/Humlal/Downloads/Compressed/node-webkit-v0.10.5-win-ia32/index.html:14:13) at asd (file:///C:/Users/Humlal/Downloads/Compressed/node-webkit-v0.10.5-win-ia32/index.html:14:13)
Yes, normal Javascript works on Node webkit.
Node runs a Javascript V8 engine, so any JS function will be understood in Node.
Your error is the following :
var asd = document.title; //This is a string
setTimeout(asd(),1000); //You call asd as a function, which does not exist, hence the error
EDIT :
With the new variable name, that should work :
var blinkOrder = 20;
var blinkNumber = 12;
var asdf = document.title;
function asd(){
if (blinkNumber >= blinkOrder) {
document.title = ' hi';
blinkNumber = 0;
}
else{
document.title = asdf;
blinkNumber++;
setTimeout(asd(),1000);
}
}
asd();
Even though I understand the downvotes, I would like to add this answer :
Be careful with hoisting (http://www.w3schools.com/js/js_hoisting.asp)!
Functions and variables are hoisted, but functions take precedence is JS in hoisting, so asd, in your code, is first assigned the function, and then the document.title value.
console.log(asd); // asd(), because even if the function is defined further
// in the code, it is hoisted
var asd = document.title;
console.log(asd); // document.title value, so the string of the page title
function asd(){
if (blinkNumber >= blinkOrder) {
document.title = ' hi';
blinkNumber = 0;
}
else{
document.title = asd; // Why ??!?!
blinkNumber++;
}
setTimeout(asd(),1000); // setTimeout() is expecting a function reference!
}
asd(); // Here, asd has been assigned the document.title value, and a string, not being a function, cannot be invoked, thus the error thrown.