Re: Causing File Download on Page Load
- From: "Jonathan Wood" <jwood@xxxxxxxxxxxxxxxx>
- Date: Sat, 23 May 2009 08:56:15 -0600
'PointedEars',
I very much appreciate the additional details.
For example, I'm not sure I understand the difference between putting code
in the onload event or just sticking it in the body (as ASP.NET will do when
I register a start-up script),
Script code in the `onload' event-handler attribute value of the BODY
element (or in another event listener for the `load' event of the
corresponding DOM object) will be executed when the document has been loaded.
Script code in the document head or body is executed while the document is
being loaded.
So script in the onload handler executes after the document is finished loading? And you prefer that approach because it ensures my script does not somehow prevent the document from loading completely? Makes good sense to me!
I have no idea what is meant in the TODO comment about using a wrapper,
on* properties are proprietary (non-standard). For an approach that targets
maximum possible compatibility (one that is "cross-browser"), a wrapper
method is necessary that prefers the standard-compliant methods
addEventListener() and removeEventListener() over assigning a Function
object reference or `null' to those properties, respectively.
<http://msdn.microsoft.com/en-us/library/ms536973(VS.85).aspx>
Okay. (Didn't see anything at that link about event listeners though.)
Such a wrapper method uses feature detection to determine if either method
is probably callable (using the user-defined isMethod() method above). If
yes, it calls them; if no, it makes the assignment instead.
If isMethod is a user-defined method, I haven't seen the definition for it. (Perhaps you meant predefined?)
However, in this case the event listeners have been specified in the markup
and not using a wrapper. Therefore, no Function object reference would be
available for passing it to EventTarget::removeEventListener(). And one
might need to rely on that the proprietary properties are supported because
AFAIK they cannot be reliably feature-tested and so a wrapper method would
not be of much use *here*. Sorry for causing confusion.
So, does this mean you would just leave that part of your original code as is? (Which simply assigns null to onload and onunload?)
And may I ask the main reason for removing the handlers for these events in download.action? I know you don't want to trigger a second download, but I'm not sure I see where that could happen. And a page refresh would just reset them again anyway, right?
Nevertheless, if we assumed that the event listeners would have been added
using script instead --
[...]
I understand that you are battling here with issues of browser compatibility and I've printed out your post. But it's pretty rough reading for me at this stage. Are you just providing this as complete information, or do you think it should be incorporated into what I'm doing here?
(It would appear there was not sufficient reason to remove
_removeEventListener() from dhtml.js, if it was there before.)
and I just don't know the intent of most statements in the code.
You can ask about them, of course, and I'll do my best to explain, but you
need to make an effort in learning -- that is, *self-study* -- in order to
accomplish anything here.
Sure, and sorry if I sometimes seem impatient. The fact is that I'm a bit overloaded here. My background is with non-Web development and over the past year or two have been learning .NET, ASP.NET, C#, HTML, CSS, SQL and I guess I should add javascript to that list. And, now, I'm under an extremely heavy workload. So it should be understandable that I get a little frustrated when some things come a little harder than it seems they should.
But I do apprecate your time in fleshing out some of the details for me. I am making an effort but this discussion has opened my eyes to a few things.
(BTW, it's come to my attention that some shareware sites use iframe tags to perform this task: <iframe style="display:none;" height="0" width="0" src="url"></iframe> Of course, that approach has it's own issues dealing with browser differences.)
Thanks!
Jonathan
.
- Follow-Ups:
- Re: Causing File Download on Page Load
- From: Thomas 'PointedEars' Lahn
- Re: Causing File Download on Page Load
- References:
- Causing File Download on Page Load
- From: Jonathan Wood
- Re: Causing File Download on Page Load
- From: Thomas 'PointedEars' Lahn
- Re: Causing File Download on Page Load
- From: Jonathan Wood
- Re: Causing File Download on Page Load
- From: Thomas 'PointedEars' Lahn
- Causing File Download on Page Load
- Prev by Date: Re: a problem with frames
- Next by Date: Nike dunk high shoes wholesale\retail
- Previous by thread: Re: Causing File Download on Page Load
- Next by thread: Re: Causing File Download on Page Load
- Index(es):
Relevant Pages
|