大约有 48,000 项符合查询结果(耗时:0.0153秒) [XML]
addEventListener vs onclick
...avaScript programmers thinks that the event name is for example onclick or onload. on is not a part of event name. Correct event names are click and load, and that's how event names are passed to .addEventListener().
Works in almost all browser. If you still have to support IE <= 8, you can use a...
The simplest possible JavaScript countdown timer? [closed]
...0) {
timer = duration;
}
}, 1000);
}
window.onload = function () {
var fiveMinutes = 60 * 5,
display = document.querySelector('#time');
startTimer(fiveMinutes, display);
};
<body>
<div>Registration closes in <span id="time">0...
How to make the window full screen with Javascript (stretching all over the screen)
...ll screen in JavaScript:
<script type="text/javascript">
window.onload = maxWindow;
function maxWindow() {
window.moveTo(0, 0);
if (document.all) {
top.window.resizeTo(screen.availWidth, screen.availHeight);
}
else if (document.layers || ...
How do I return the response from an asynchronous call?
...se(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
resolve(this.responseText);
};
xhr.onerror = reject;
xhr.open('GET', url);
xhr.send();
});
}
ajax("/echo/json")
.then(function(result) {
// Code depending on result
})
...
Preview an image before it is uploaded
...p; input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]); // convert to base64 string
}
}
$("#imgInp").change(function() {
readURL(this);
});
&l...
Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference
... depends on the case. Let's try to trace some common behavior again:
img.onload may be called sometime in the future, when (and if) the image has successfully loaded.
setTimeout may be called sometime in the future, after the delay has expired and the timeout hasn't been canceled by clearTimeout. ...
How to get year/month/day from a date object?
alert(dateObj) gives Wed Dec 30 2009 00:00:00 GMT+0800
16 Answers
16
...
Is it possible to ping a server from Javascript?
...ip = ip;
var _that = this;
this.img = new Image();
this.img.onload = function() {_that.good();};
this.img.onerror = function() {_that.good();};
this.start = new Date().getTime();
this.img.src = "http://" + ip;
this.timer = setTimeout(function() { _that.bad();}, 1500);...
How to detect internet speed in JavaScript?
...really accurate, the idea is load image with a known file size then in its onload event measure how much time passed until that event was triggered, and divide this time in the image file size.
Example can be found here: Calculate speed using javascript
Test case applying the fix suggested there:
...
Displaying Windows command prompt output and redirecting it to a file
...ike ping or 7z.exe
– Wes Larson
Feb 20 '16 at 1:14
Not working for interactive commands instead of dir. Example: chkds...
