Here is a quick question.. for Javascript Experts.
I have a JS code that opens an about::blank IE window.
I close this new window opened if the parent window is about to close,using window.close() in onunload (or onbeforeunload) it will get closed!
But if I push the contents of PDF in aspx file, it will not close the window with the same logic.. Here is my code example.
------------
Parent file : (parent.aspx script)
<script type="text/javascript" language="javascript">
var pdf_window = null;
function OpenFormPdfViewer(user_form_id)
{
CloseFormPdfViewer();
pdf_window = window.open("sample.aspx");
if ( pdf_window != null )
{
document.all["ButtonNext"].disabled = false;
this.focus();
}
}
function closeIt()
{
if ( pdf_window != null)
{
alert('Closing Child window');
pdf_window.close();
pdf_window = null;
}
}
function CloseFormPdfViewer()
{
closeit();
}
window.onbeforeunload = function(){closeIt();}
</script>
This will close the new browser if I navigate out of this page: but if I change the
pdf_window = window.open("sample.aspx");
to
pdf_window = window.open("viewformpdf.aspx?f=100");
to open a PDF file in the new IE browser, the same logic to close will not work.
here is my viewformpdf.aspx code (part of it):
---------------
byte[] bytes = GetFormPdf(m_user_form_id);
Debug.Assert(bytes != null);
if ( (bytes != null) && (bytes.Length > 0) )
{
Response.ClearHeaders();
Response.ClearContent();
Response.Clear();
Response.ContentType = "application/pdf";
Response.AppendHeader("content-disposition", "inline");
Response.BinaryWrite(bytes);
Response.End();
}
---------------
Am I missing something?!? this will not work if I try to open any text file in a new window as well.
---------------
I am not sure why it will work for any normal page while not on PDf/txt !?!
Thanks for the help!
Jay
I have a JS code that opens an about::blank IE window.
I close this new window opened if the parent window is about to close,using window.close() in onunload (or onbeforeunload) it will get closed!
But if I push the contents of PDF in aspx file, it will not close the window with the same logic.. Here is my code example.
------------
Parent file : (parent.aspx script)
<script type="text/javascript" language="javascript">
var pdf_window = null;
function OpenFormPdfViewer(user_form_id)
{
CloseFormPdfViewer();
pdf_window = window.open("sample.aspx");
if ( pdf_window != null )
{
document.all["ButtonNext"].disabled = false;
this.focus();
}
}
function closeIt()
{
if ( pdf_window != null)
{
alert('Closing Child window');
pdf_window.close();
pdf_window = null;
}
}
function CloseFormPdfViewer()
{
closeit();
}
window.onbeforeunload = function(){closeIt();}
</script>
This will close the new browser if I navigate out of this page: but if I change the
pdf_window = window.open("sample.aspx");
to
pdf_window = window.open("viewformpdf.aspx?f=100");
to open a PDF file in the new IE browser, the same logic to close will not work.
here is my viewformpdf.aspx code (part of it):
---------------
byte[] bytes = GetFormPdf(m_user_form_id);
Debug.Assert(bytes != null);
if ( (bytes != null) && (bytes.Length > 0) )
{
Response.ClearHeaders();
Response.ClearContent();
Response.Clear();
Response.ContentType = "application/pdf";
Response.AppendHeader("content-disposition", "inline");
Response.BinaryWrite(bytes);
Response.End();
}
---------------
Am I missing something?!? this will not work if I try to open any text file in a new window as well.
---------------
I am not sure why it will work for any normal page while not on PDf/txt !?!
Thanks for the help!
Jay