"Baffin Shea" <ba****@shea.com> wrote in message
news:3f********@newsgate.hknet.com...
<snip>
<form>
<input type=image src="cde.gif" onclick="NewWindow()">
</form>
<snip>Do you have any idea. Thank you.
<snip>
As Lasse and I suspected, the problem is the failure to cancel the
default action on he input element (which is to submit the form to the
URL specified in the (missing) action attribute of the form element).
And Lasse's suggestion of adding - return false; - to the onclick
handler will cancel that action in all of the browsers that support the
onclick event on <input type="image"> elements. Wider support can be
achieved by providing the FORM element with an onsubmit handler that
cancels the submit by returning false.
I still think it would be better to abandon the window opening idea
entirely but, given what the script does now, it is possible to achieve
exactly the same effect with pure HTML (and if something can be done
with HTML instead of JavaScript it should be done with HTML). If the
FORM element specified "abc.asp" as its ACTION attribute and had a
TARGET attribute of "_blank" you cold forget the script entirely and
achieve the same result:-
<form action="abc.asp" name="fName" target="_blank">
<input type=image src="cde.gif" alt="???">
</form>
One of the advantages of a pure HTML approach to opening new window is
that it reduces the number of possible outcomes when the user clicks the
button down to four. And it is much easier to design a workable UI if a
user action only results in any one of four unpredictable consequences.
One would be ideal but it is still and improvement on the six or seven
possible outcomes of the JavaScript based attempt.
Richard.