Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #33036
| Path | csiph.com!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Which type of network access for this situation? |
| Date | Tue, 18 Apr 2017 02:52:14 +0200 |
| Organization | PointedEars Software (PES) |
| Lines | 53 |
| Message-ID | <1611458.0Y0JHutS3l@PointedEars.de> (permalink) |
| References | <7e444aec-2938-4da7-9162-54b71bbe7be7@googlegroups.com> <od3kp9$mr9$1@news.albasani.net> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Trace | solani.org 1492476735 27680 eJwFwQEBACAIA7BKID/eOIrSP4IbIz1rIplgs4V9Vt0NcT21GwrwG+DUFM9ZFmzrkj17Y3wW+xCq (18 Apr 2017 00:52:15 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Tue, 18 Apr 2017 00:52:15 +0000 (UTC) |
| User-Agent | KNode/4.14.2 |
| X-User-ID | eJwNxkkBwDAIBEBL4QY5QLL+JbTzGhMn31A3V4Oh38yieu4cWGRzLx0pEcPbpn/E7pxpESWX/aSCkt40tO4HclEVkw== |
| X-Face | %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v |
| X-NNTP-Posting-Host | eJwNyskBwCAIBMCWQtzlKAcF+i9B3zNcKnoMSgWH06wQ1AD0bcPT/Fzq74ygJateQD4zXRt+ASIhESI= |
| Face | iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== |
| Cancel-Lock | sha1:B8rm465ixrRHNTtEj20eI6ulFi8= |
| Xref | csiph.com comp.lang.javascript:33036 |
Show key headers only | View raw
Stefan Weiss wrote:
> bit-naughty@hotmail.com wrote:
>> Suppose after a page is loaded, I want to download some stuff (text or
>> HTML) later, or even immediately and display it. But NOT on a button
>> click, more like say, after a timer goes off or something. What type of
>> networking shit do I use for this? Does it call for AJAX, WebSockets or
>> the DataChannel part of the WebRTC API, which I just got to know about?
>> I'm still not really clear about what the exact differences between each
>> of them are....
>
> Use the XMLHttpRequest object. […]
Not necessarily. If a resource is to be downloaded to be saved as a file in
the filesystem in a user-specified location after a “timer goes off”, then a
simple
var timer = window.setTimeout(function () {
window.clearTimeout(timer);
window.location = "…";
}, 42);
suffices, where 42 is the number of milliseconds after this call that the
“timer goes off” (in backwards-compatible code, it should not be less than
10). The resource needs to be served with the proper MIME media type; if it
should be downloaded to be saved as a file, then “application/octet-stream”
will trigger the browser’s download dialog.
Any suitable set of statements can be used instead of the assignment to
“window.location”. For example, if an image resource is to be displayed,
code to set the “src” property of an “img” element object, optionally create
the latter and insert the corresponding “img” node into the document tree
first, can be used.
If one uses window.setTimeout(), one should also handle the case of
navigating away before the “timer goes off”, so as not to potentially
execute code that potentielly produces errors because of missing objects:
window.onunload = function () {
window.clearTimeout(timer);
};
It may be useful to establish a timeout registry that clears all registered
timeouts in that case.
The usual caveats regarding the use of host-provided features apply.
--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Which type of network access for this situation? bit-naughty@hotmail.com - 2017-04-17 11:53 -0700
Re: Which type of network access for this situation? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-04-18 00:57 +0100
Re: Which type of network access for this situation? Stefan Weiss <krewecherl@gmail.com> - 2017-04-18 01:57 +0200
Re: Which type of network access for this situation? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-04-18 02:52 +0200
Re: Which type of network access for this situation? Stefan Weiss <krewecherl@gmail.com> - 2017-04-18 03:13 +0200
Re: Which type of network access for this situation? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-04-18 05:40 +0200
Re: Which type of network access for this situation? bit-naughty@hotmail.com - 2017-04-18 08:22 -0700
Re: Which type of network access for this situation? bit-naughty@hotmail.com - 2017-04-18 08:28 -0700
Re: Which type of network access for this situation? Jon Ribbens <jon+usenet@unequivocal.eu> - 2017-04-18 16:08 +0000
Re: Which type of network access for this situation? bit-naughty@hotmail.com - 2017-04-19 23:44 -0700
Re: Which type of network access for this situation? Jon Ribbens <jon+usenet@unequivocal.eu> - 2017-04-20 10:15 +0000
Re: Which type of network access for this situation? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-20 12:56 +0200
Re: Which type of network access for this situation? maherrj@googlemail.com - 2017-04-17 17:23 -0700
Re: Which type of network access for this situation? Stefan Weiss <krewecherl@gmail.com> - 2017-04-18 03:29 +0200
csiph-web