We are experiencing a problem when a page is inside an iframe.
We have links to download certain files which are actually served by an asp
page. However, once the user clicks on the link and downloads the
attachment, any references to document object on the page's javascript code
results in object undefined error. Basically we have a button which calls a
javascript function and inside the function document object is referred to.
IE reports an error at this location. This page works fine if the page is
the top window.
Here is the code for the main page and also the as page served for the
iframe...
Outer HTML page
HTMLTest.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<meta http-equiv="Expires" content="0">
</head>
<body>
<P>This just place holder. click the button inside the iframe.</P>
<iframe src="test.asp"></iframe>
</body>
</html>
Asp page for the iframe ..
Test.asp
<%@ Language=VBScript %>
<%
if Request.Form("buttonSubmit") <> "" then
Dim fileName
Dim str1
Dim str2
fileName = "DynamicText.txt"
'These are the strings that are used to build the text file.
str1 = "<-- Hello -->"
str2 = "This is a demo on creating dynamic text file"
'ContentType specifies the MIME type of this header.
Response.ContentType = "text/plain"
'The AddHeader method adds an HTML header with a specified value.
'Content-disposition forces the browser to download.
Response.AddHeader "content-disposition", "attachment; filename=""" &
fileName & """"
Response.Write str1 & vbnewline
Response.Write str2
Response.End
End if
%>
<HTML>
<HEAD>
<TITLE> Demo on Creating Dynamic Text File </TITLE>
</HEAD>
<BODY>
<h4> This is a demo on creating a dynamic text file </h4>
<FORM action="" method=POST id=form1 name=form1>
<INPUT type="submit" value="Download TextFile" id=buttonSubmit
name=buttonSubmit>
<br />
<span style="background-color:blue;cursor:default;"
onclick="javascript:showAlert();">Click here after downloading.</span>
</FORM>
<script language="javascript" type="text/javascript">
function showAlert()
{
var str = document.body.innerHTML;
window.alert("If you see this message there is no problem.");
}
</script>
</BODY>
</HTML>
seems to be an IE bug, is there a way around it??
thanks
Pat Malay
|