大约有 17,000 项符合查询结果(耗时:0.0258秒) [XML]
Pure JavaScript equivalent of jQuery's $.ready() - how to call a function when the page/DOM is ready
...;
<html>
<head>
</head>
<body>
Your HTML here
<script>
// self executing function here
(function() {
// your page initialization code here
// the DOM will be available here
})();
</script>
</body>
</html>
For modern browsers (anything from ...
How to open a local disk file with JavaScript?
...tack Overflow (6/6/2018 - https://stackoverflow.com/questions/13405129/javascript-create-and-save-file )
var eventMouse = document.createEvent("MouseEvents")
eventMouse.initMouseEvent("click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
elem.dispatchEvent(eventMous...
Drawing an image from a data URL to a canvas
...canvas_id');
var ctx = myCanvas.getContext('2d');
var img = new Image;
img.onload = function(){
ctx.drawImage(img,0,0); // Or at whatever offset you like
};
img.src = strDataURI;
Edit: I previously suggested in this space that it might not be necessary to use the onload handler when a data URI i...
Convert SVG to image (JPEG, PNG, etc.) in the browser
...g+xml;charset=utf-8"});
var url = DOMURL.createObjectURL(svgBlob);
img.onload = function () {
ctx.drawImage(img, 0, 0);
DOMURL.revokeObjectURL(url);
if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob)
{
var blob = canvas.msToBlob();
...
Difference between DOMContentLoaded and load events
... Fyi, the same MDN link [now] also says: "Note: Stylesheet loads block script execution, so if you have a <script> after a <link rel="stylesheet" ...>, the page will not finish parsing - and DOMContentLoaded will not fire - until the stylesheet is loaded."
– Nic...
Send POST data using XMLHttpRequest
I'd like to send some data using an XMLHttpRequest in JavaScript.
13 Answers
13
...
Detect blocked popup in Chrome
I am aware of javascript techniques to detect whether a popup is blocked in other browsers (as described in the answer to this question ). Here's the basic test:
...
How to add image to canvas
... base_image = new Image();
base_image.src = 'img/base.png';
base_image.onload = function(){
context.drawImage(base_image, 0, 0);
}
}
I.e. draw the image in the onload callback of the image.
share
|
...
How to display loading message when an iFrame is loading?
...
With the iframe onload function you can remove the CSS background image.
– Hugo Cox
Oct 20 '17 at 0:09
1
...
Is it possible to ping a server from Javascript?
...this:
put ping.html on the server with or without any content, on the javascript do same as below:
<script>
function ping(){
$.ajax({
url: 'ping.html',
success: function(result){
alert('reply');
},
error: function(result){
...