Re: onclick handler and automation

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Igor Tandetnik (itandetnik_at_mvps.org)
Date: 07/19/04


Date: Mon, 19 Jul 2004 10:55:03 -0400


"jmcfetridge@coast.com" <jmcfetridgecoastcom@discussions.microsoft.com>
wrote in message
news:D5FF50AC-E3E5-47A3-9FA3-22DD8D316D95@microsoft.com
> However the frustrating thing if the varresult which is var
> in below code segment is VT_EMPTY even when the return is true from
> the script. My code looks like:
>
> And the script looks like
>
> function f2()
> {
> window.alert("This is an alert");
> return false;
> }

What does the onclick attribute look like? Is it onclick="f2();" or
onclick="return f2();" ? In the first case, the return value of f2 is
silently ignored by MSHTML. Note - you don't call f2() itself, you call
a script handler which itself is a function that calls f2. In other
words,

<a id="elem" onclick="f2()">...</a>

is equivalent to

<a id="elem">...</a>
<script>
elem.onclick=function(){f2();}
</script>

Note that the function assigned as a handler does not return any value,
even though f2() does.

-- 
With best wishes,
    Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Relevant Pages

  • Re: Debugging Help Please! :) File renaming...
    ... This code segment is part of a larger script that moves PST files so ... How can you have two files of the same name in the same folder? ...
    (microsoft.public.scripting.vbscript)
  • Re: window object
    ... Within a script, every reference to an object amounts to two ... calls from the scripting engine to the DHTML Object Model. ... var sText = document.all.div1.innerText; ...
    (comp.lang.javascript)
  • Re: Change IP related values due to WAN design change
    ... Unknown network, ... For the cost of testing a dangerous script in a big ... > recurse your text file into an array. ... > var newSettings = new NetworkSettings; ...
    (microsoft.public.windows.server.scripting)
  • Re: problem with logoff script
    ... the script engine as a process on the workstation and should execute cleanly ... var fso = new ActiveXObject; ... sho.popup('An error occured attempting to get the Operating System Type. ... // Retrieve the script application ...
    (microsoft.public.win2000.group_policy)
  • Re: Script for adding and deleting rows to a table
    ... that is one long script. ... var numRows = document.getElementById.rows.length; ... //Get Reference to cell that needs to be changed ...
    (comp.lang.javascript)