Path: csiph.com!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Why does savepng workl with eventlistener but not by call from form? Date: Fri, 11 Nov 2016 16:08:16 +0100 Organization: PointedEars Software (PES) Lines: 44 Message-ID: <2828265.aV6nBDHxoP@PointedEars.de> References: <58b433c6-37a6-45de-bc70-05ec835510ff@googlegroups.com> <17n7y8md13g1b$.kznrbim03ls$.dlg@40tude.net> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1478876897 22677 eJwNwoERADEEBMCWgnOknMfov4T87LpR2AE64fsDuqCOcFkQPZ+ehpscS6Yqb2C0Zapv5T78ghA+ (11 Nov 2016 15:08:17 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Fri, 11 Nov 2016 15:08:17 +0000 (UTC) User-Agent: KNode/4.14.2 Cancel-Lock: sha1:607xQYKkkPPFNSheGBzye5wvUd8= X-NNTP-Posting-Host: eJwNyUEBACAIA8BKTBlCHFDpH0G/d5wG20uNpmx2i8YZJLZUrGPuyMIs6PVvRon4XfC8PmY+CEUQOg== X-User-ID: eJwNyscRADEIBMGUQCxG4XCY/EM41Tz6MyrGVg5Tg67uc2zYaYA+OBsfx3bKXSgH1QhdzQoPr7xexP2+fqUw8ANDIRUH Xref: csiph.com comp.lang.javascript:31697 JJ wrote: > On Thu, 10 Nov 2016 15:47:37 -0800 (PST), jonas.thornvall@gmail.com wrote: >> But what does click() do, it can't start the eventhandler because it is >> inside the function that will be called from the handler, restart? > > click() simulates a click event. > It's OOP, so click() belongs to anobject. > So, anobject.click() clicks the anobject. It is a proprietary, legacy method, though, not even defined in WHATWG HTML. The standards-compliant approach is to dispatch a synthetic “click” event to the element object. This has become a lot easier since the UI Events Specification that deprecated the Event::init*Event() methods, with their insanely long parameter lists, in favor of proper constructors: anObject.dispatchEvent(new MouseEvent("click", { view: document.defaultView, bubbles: true, cancelable: true })); [Formerly: var mouseEvent = document.createEvent("MouseEvents"); mouseEvent.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); anObject.dispatchEvent(mouseEvent); Lesson to be learned: Design functions/methods to accept references to parameter/option objects, and not more than 5 arguments [unless it is a list of values of equal meaning, see e.g. Math.max()]. Otherwise nobody is going to remember the correct argument order, you will be sacrificing flexibility, and the caller’s code will look like Chinese (when they are not Chinese).] pp. -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.