Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #33228
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: How would using await be possible in an event handler content attribute? |
| Date | 2017-05-06 01:16 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <4012654.cEBGB3zze1@PointedEars.de> (permalink) |
| References | <oehnpk$i0b$1@news.albasani.net> <1885432.OBFZWjSADL@PointedEars.de> |
Thomas 'PointedEars' Lahn wrote:
> Martin Honnen wrote:
>> If I simply use
>>
>> <input type="button" value="test"
>> onclick="var response = await fetch(location.href);">
>>
>> I get an error "Unexpected identifier".
Me too. To be precise, a SyntaxError exception with that message is thrown
and not caught.
>> Is there any way to designate an event handler content attribute as an
>> async function body?
>
> I do not know of any. The obvious solution might be
>
> onclick="(async function () {
> var response = await fetch(location.href);
> }())"
>
> or
>
> onclick="async function blub () {
> var response = await fetch(location.href);
> }; blub();"
Both work in
| Chromium 57.0.2987.98 (Developer Build) Built on 8.7, running on Debian stretch/sid (64-bit)
| Revision a6a06b78087c9fdb4b12fe0ac1b87fdc10179f8b
| OS Linux
| JavaScript V8 5.7.492.63
| […]
| User Agent Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36
| Command Line /usr/lib/chromium/chromium --disk-cache-size=44040192 --show-component-extension-options --ppapi-flash-path=/usr/lib/pepperflashplugin
nonfree/libpepflashplayer.so --ppapi-flash-version=23.0.0.207 --flag-switches-begin --ignore-gpu-blacklist --flag-switches-end
(<chrome://version>)
So if I had to use one of them, I would use the first one (the AFE).
However, why would one want to produce spaghetti code?
--
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 | Find similar | Unroll thread
How would using await be possible in an event handler content attribute? Martin Honnen <martin.honnen@gmx.de> - 2017-05-05 13:30 +0200
Re: How would using await be possible in an event handler content attribute? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-05 20:02 +0200
Re: How would using await be possible in an event handler content attribute? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-06 01:16 +0200
csiph-web