VK said:
Richard Cornford is an expert in the "set up a straw man"
tactique: so you never can be sure with him did he really
misunderstood something or is he just pulling out more
argumentation out of you waiting for some error to jump to
"Jump to"?
Let's take it as he really missed both
javascript:void(expression) and (function(){})()
usage.
That seems very unlikely. Of course it may seem that way to you because
your understanding of this subject is such a tangles mass of
misconceptions that you cannot actually implement the simplest javascript
function effectively.
1) javascript:void(expression) in bookmarklet
javascript: pseudo-protocol was made to replace the current page by
content generated by the return value of the invoked javascript code.
Return values are things that belong to functions. Javascript pseudo
protocol URLs are not executed as functions.
If the invoked javascript code returns nothing
In the examples under discussion the evoked javascript code is an
Expression and Expressions do not return values they evaluate to values,
and they can never evaluate to "nothing".
then UA stays on the same page.
The UA always stays on the same page, it is just that the contents of
that page may be replaced with the value of the expression if the browser
sees that value a suited to the action. The undefined value is never seen
as suited as a source to replace the page. Other values that have
falseness generally are not considered suited either, but browsers differ
in what they may employ.
But in any case invoking javascript: bookmarklet puts the
browser into navigation mode
Activating javascript pseudo protocol URLs certainly does that in at
least some browsers (most notably IE).
until it gets informed that will be no navigation.
In the case of IE <= 6 at least nothing will get the page out of its
altered state except the contents of the page being replaced by the
javascript pseudo protocol bookmark evaluating to a value that will
replace its contents.
So by the procedure it is very close to click a link with
"204 No Content" server response behind.
What is like a 204 response? Having the Expression evaluate as the
undefined value certainly does not get the page out of its altered state,
and having it evaluate as value that will replace the contents of the
page would be better compared with a 200 response.
Remember that we have repeatedly shown you that a javascript
pseudo-protocol HREF consisting of nothing but - javascript:void 0; -
will put IE <= 6 into its pending navigation state reliably:-
<URL:
http://groups.google.com/group/comp..._frm/thread/4d2e99b2a8bdbbd2/bfc201699aef169e
<URL:
http://groups.google.com/group/comp..._frm/thread/d156ea8137cdd1b4/1c07ad60e4d8fe1f
I like to let the system know in advance and right away
that no matter what happens where will be no effective
navigation by this link.
If that is what you were doing then maybe it would be worthwhile, but
that is not what happens.
This is why I'm using javascript:void(the rest)
If that is what you were doing then maybe it would be worthwhile, but
that is not what happens.
First the browser does not get any advanced warring form the use of void
operator, the expression must still be evaluated first. It does not learn
anything any sooner. And second, the browser does not get tipped off that
navigation is not going to happen. IE <= 6 goes into its altered state
when the URL is activated and it says in that state until either the
contents of the current page are replaced or the page is replaced with
another.
And if the expression that is the operand for - void - is a call to a
function that has no return value then the expression is going to
evaluate as undefined, so using that expression as the operand for the
void operator actually delays the browser in finding out that the value
of the whole expression is going to be the undefined value.
Thus "know in advance and right away" is a total fiction, and "no matter
what happens where will be no effective navigation" is meaningless as the
browser (at least IE <= 6) still be leaves it is about to be navigated
anyway.
2) Shy namespace
Bookmarklet code runs in the same global space as the current page.
This way if the page already has its own script with say
var AJAX = new AjaxRequest();
and your bookmarklet has
javascript:var AJAX=new AjaxRequest()
then after executing your bookmarklet the existing script on
the page will be FUBAR.
Unless the point of the javascript URL is to modify the script on the
page so it behaves as the user desires.
Moreover any var in your bookmarlet will be created as
global var so stay polluting the global scope.
"Stay polluting the global scope"? What is "stay polluting"?
By using anonymous function call you keep your bookmarlet
"shy" and not messing with the existing context.
You mean that inside the anonymous function you have a private scope to
play with that will not impact upon the global scope, unless that is
wanted. We know this, indeed we spend a couple of weeks of posts
battering that fact into you just last year.
This is why I'm using javascript:void((function()
{the rest})())
No, that is why people use - javascript
function(){ ... })(); -. The use
of the - void - operator is superfluous whenever the function does not
have a return value as the scope restrictions are a consequence of the
use of the function alone.
if(window) check is already signed off as a Cargo Cult
programming element.
Yes, you only made one post trying to present one of your fictions as an
explanation for your suggesting that mystical incantation. Hopefully some
time soon you will see the futility in wrapping calls to functions that
have no return value in void operations, and stop posting bogus attempts
to justify your mystical incarnations.
The main fun of it is that I was for years an opponent of
window, document, getElementById and other parasite checks.
Another proof of how does the environment affect us in
oftenly hidden ways.
That is more proof that a determined fool can say a fool for ever.
Richard.