|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Hidding a <div> with csv content
submitted form. When the form is submitted, some javascript sets a hidden div, to displaying, eg: document.getElementById('hiddendiv').style.display = ''; This div, simply has the words "building csv file, please wait", and is used, because their is no indication in IE, as to what is happening, when the user clicks on 'Results in CSV format', to return a report as a CSV file. The form is submitted to the hidden iframe. The asp page that is used in the action of the form (run.csv.report.asp), has a content type of "text/comma-separated-values" and a response header of ""Content-Disposition","filename=report.csv". If the report returns no records, in the asp page, I can return either; <html> <body onload=" window.top.document.getElementById('hiddendiv').style.display='none'; alert('No records have been found for your report');"></body></html> Or if the number of records is greater than 65535 (maximum number of rows Excel can handle); <html> <body onload=" window.top.document.getElementById('hiddendiv').style.display='none'; alert('Too many records for Excel.\nPlease refine your search criteria'');"></body></html> However, if records are found, because the response is a csv, (ie: response.write "field1,field2,field3" & vbCrLf) I can not use the javascript of; window.top.document.getElementById('hiddendiv').style.display='none'; Otherwise, this line is included in the csv file and the div is not hidden when the report is finished. Is there anyway to hide the div on the client, after the server has created the report? I am not 100% sure that this will work in all browsers, but you can query the
elements 'readyState' in a loop or something similar, I have made a quick example to show: (quick and dirty, i know) <html> <head> <script language="javascript"> var timer function xcheckStatus() { timer = setTimeout('loopstatus()',20) } function loopstatus() { clearTimeout(timer) window.status = document.getElementById("myiframe").readyState timer = setTimeout('loopstatus()',20) } </script> </head> <body onload="xcheckStatus()"> <input type="text" name="bob" id="myurl"><input type="button" name="btn" value="go" onclick="document.getElementById('myiframe').src = document.getElementById('myurl').value"> <iframe id="myiframe" src="testeriframe.asp" ></iframe> </body> </html> When the readyState comes back as completed, it is done. However I did not test this using an csv file, just html pages. Show quote "Ruskin Hardie" wrote: > There is an iframe in my document that is hidden, which is the target for a > submitted form. When the form is submitted, some javascript sets a hidden > div, to displaying, eg: > > document.getElementById('hiddendiv').style.display = ''; > > This div, simply has the words "building csv file, please wait", and is > used, because their is no indication in IE, as to what is happening, when > the user clicks on 'Results in CSV format', to return a report as a CSV > file. > > The form is submitted to the hidden iframe. The asp page that is used in the > action of the form (run.csv.report.asp), has a content type of > "text/comma-separated-values" and a response header of > ""Content-Disposition","filename=report.csv". > > If the report returns no records, in the asp page, I can return either; > <html> > <body onload=" > window.top.document.getElementById('hiddendiv').style.display='none'; > alert('No records have been found for your report');"></body></html> > > Or if the number of records is greater than 65535 (maximum number of rows > Excel can handle); > <html> > <body onload=" > window.top.document.getElementById('hiddendiv').style.display='none'; > alert('Too many records for Excel.\nPlease refine your search > criteria'');"></body></html> > > However, if records are found, because the response is a csv, (ie: > response.write "field1,field2,field3" & vbCrLf) I can not use the javascript > of; > > window.top.document.getElementById('hiddendiv').style.display='none'; > > Otherwise, this line is included in the csv file and the div is not hidden > when the report is finished. > > Is there anyway to hide the div on the client, after the server has created > the report? > > > You have sparked my curiosity!!!
In further testing (and optimized codeing) I have discovered that you will get back 'interactive' as the last readyState due to the save / open / cancel dialog. <html> <head> <script language="javascript" for="myiframe" event="onreadystatechange()"> document.getElementById("mytextarea").value = document.getElementById("myiframe").readyState + "\n" + document.getElementById("mytextarea").value </script> </head> <body> <input type="text" name="bob" id="myurl" /> <input type="button" name="btn" value="go" onclick="document.getElementById('myiframe').src = document.getElementById('myurl').value" /> <br /> <iframe id="myiframe" src="testeriframe.asp" ></iframe> <br /> <textarea id="mytextarea" rows=10></textarea> </body> </html> Show quote "Ruskin Hardie" wrote: > There is an iframe in my document that is hidden, which is the target for a > submitted form. When the form is submitted, some javascript sets a hidden > div, to displaying, eg: > > document.getElementById('hiddendiv').style.display = ''; > > This div, simply has the words "building csv file, please wait", and is > used, because their is no indication in IE, as to what is happening, when > the user clicks on 'Results in CSV format', to return a report as a CSV > file. > > The form is submitted to the hidden iframe. The asp page that is used in the > action of the form (run.csv.report.asp), has a content type of > "text/comma-separated-values" and a response header of > ""Content-Disposition","filename=report.csv". > > If the report returns no records, in the asp page, I can return either; > <html> > <body onload=" > window.top.document.getElementById('hiddendiv').style.display='none'; > alert('No records have been found for your report');"></body></html> > > Or if the number of records is greater than 65535 (maximum number of rows > Excel can handle); > <html> > <body onload=" > window.top.document.getElementById('hiddendiv').style.display='none'; > alert('Too many records for Excel.\nPlease refine your search > criteria'');"></body></html> > > However, if records are found, because the response is a csv, (ie: > response.write "field1,field2,field3" & vbCrLf) I can not use the javascript > of; > > window.top.document.getElementById('hiddendiv').style.display='none'; > > Otherwise, this line is included in the csv file and the div is not hidden > when the report is finished. > > Is there anyway to hide the div on the client, after the server has created > the report? > > > |
|||||||||||||||||||||||