Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27069
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: onclick and <a> tag question |
| Date | 2015-03-19 03:47 +0100 |
| Organization | PointedEars Software (PES) |
| Message-ID | <2047696.ZRK4UxyjuH@PointedEars.de> (permalink) |
| References | <cmugv0Fep3qU1@mid.individual.net> |
Mel Smith wrote: > On my download site I have approx 25 download links similar to the > following but simplified below: > > <a id="i116" href="http://www.example.com/files/x116.zip" > onclick="chkdld(this);">Download this file</a> > > Note that I have 'clickable' link and also an onclick attribute/property > ! _attribute_. And why the emphasis? Do you want a pat on the back for not doing mindbogglingly stupid things? > I have determined that on IE8 (at least) that the onclick operation > occurs first and then the 'download' operation follows after the chkdld() > function returns either a true or false. You want to test with modern browsers first. And nothing is returned here. > Question: > > Is this sequence (i.e., 'onclick' followed by 'download operation') > generally true across most all current common browsers. ?? Yes, to all script-supporting browsers worth their salt. The download is only a consequence of the default action for links when the browser has determined that it cannot reasonably navigate to and display the resource, or if response header or the user said that they always want to download such resources. You can cancel the default action of the “click” event by returning “false” to the event handler; in this case, as is recommended, by returning the return value of a function or method: <a href="…" onclick="return chkdld(this)">…</a> > Reason: > > I hope to use the 'onclick' sequence to start up an Ajax operation to > determine the IP address info of the user, and then send a text response > to modify the 'files' sub-directory to point to the *actual* download > sub-dir -- which I modify frequently. You do not want to do that. Doing so could be considered forgery; it will not help, and may hinder, your good standing with search engines. For forgery aside, the search engine will probably not be able to detect whether this part of your site was updated. As a rule of thumb, search engines "like" sites whose content (not: URIs) is frequently updated. > Recently, on request I've eliminated use of passwords and, instead, am > keeping a database of 'abusers' of my free service who typically start up > dozens of simultaneous downloads to try to overwhelm my server. Because > my actual download sub-dir changes frequently, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Bad idea. <http://www.w3.org/QA/Tips/uri-choose> > I thought I could use Ajax to send the *actual* 'files' sub-dir as a > response at thelast moment, then perhaps I could (somehow) revert it > later after the download is started -- but I don't know how to do this yet > (i.e., the 'reverting'). It is pointless to try and hide content from abusers this way. It is like trying to scare burglars away by locking the door of your house and hanging up outside a sign with a large red down arrow that says “The key for this door is right below your feet, under the mat.” Get a bigger house (better hosting space) or a watchdog instead (detect abusers by their connection data and request headers, and tell them 403). -- PointedEars FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix> 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
onclick and <a> tag question "Mel Smith" <syntel@cox.net> - 2015-03-18 16:44 -0700
Re: onclick and <a> tag question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-19 03:47 +0100
Re: onclick and <a> tag question "Mel Smith" <syntel@cox.net> - 2015-03-19 08:54 -0700
Re: onclick and <a> tag question "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-03-19 18:29 +0100
Re: onclick and <a> tag question "Mel Smith" <syntel@cox.net> - 2015-03-19 12:29 -0700
Re: onclick and <a> tag question "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-03-19 21:29 +0100
Re: onclick and <a> tag question "Mel Smith" <syntel@cox.net> - 2015-03-19 16:34 -0700
Re: onclick and <a> tag question "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-03-20 01:28 +0100
Re: onclick and <a> tag question "Mel Smith" <syntel@cox.net> - 2015-03-19 21:42 -0700
Re: onclick and <a> tag question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-20 12:30 +0100
Re: onclick and <a> tag question "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-03-20 13:51 +0100
csiph-web