From: DL on
Hi,

How to trigger two js events with two separate document.location or
document.location.href statements? That is, how to make the routine
return after the first non-conventional document.location call (please
see the entire text for the notion of "non-conventional ").

The page has a canvas and a form (browser = Firefox).

What I intended to do is to save the drawing the the canvas to an
image file and send the form for process upon SAVE.

Problem is it is an either or situation, that is, either able to save
the canvas content to an image file or accept the form inputs but not
both
at the same time. I can only speculate the culprits:
one is the 2 document.location references (both are needed);
and secondly, I don't know how to submit the form in such a situation.
Details below. Please let me know if it won't suffice to describe the
problem clearly.

Thanks in advance.

<canvas width="465" height="530" style="border:1px solid black;"
id="mycanvas"></canvas>

<form id="myform" action="processit.cfm" method="post">
.... input type="text"
several such fields
one iframe
and a hidden field to store the value from the iframe upon form
submission
</form>

<!-- canvas js libraries -->
<script type="text/javascript" src="/js/canvasLib1.js"></script>
<script type="text/javascript" src="/js/canvasLib2.js"></script>
<script type="text/javascript" src="/js/canvasLibN.js"></script>

<javascript ...>

function handleCanvas() {
var oCanvas = ...
...
}

document.getElementById("SaveTwo").onclick = function() {
// a) save canvas to an image file
handleCanvas(oCanvas, "PNG");

// b) send the form to the script per ACTION
document.myform.submit();

</javascript>


one of the libraries has the following lines of code:
// sends the generated file to the client
var saveFile = function(strData) {
document.location.href = strData;
}