PDA

View Full Version : How do I Refresh an IFrame?



sgmunson
10-16-2007, 06:49 PM
I'm working on a webpage that is ASP, and it has both VBScript and Javascript in it. The idea is to have a user select from various input choices in a select control, and then using the post method, bring that value into the VBScript function which then passes it along to the Javascript function that refreshes the 4 IFrames I have. My PC is XP Pro for the OPSys, and I have IIS installed and configured (rightly or wrongly, I don't know enough to know for sure). My main page is GETWRS2.asp, and is coded as follows:


<html>
<head>
<title>TESTING OF JAVASCRIPT</title>
<script language="javascript" type="text/javascript">

function RefreshIFrames(WRSNUM)
{
frames["WRSFrame"].location.href = 'WRSFrame.asp&wrs=' + WRSNUM;
frames["WRSFrame"].location.reload();
window.frames["SAFrame"].location.href = 'SAFrame.asp&wrs=' + WRSNUM;
window.frames["SAFrame"].location.reload();
window.frames["CSRFrame"].location.href = 'CSRFrame.asp&wrs=' + WRSNUM;
window.frames["CSRFrame"].location.reload();
window.frames["BENFrame"].location.href = 'BENFrame.asp&wrs=' + WRSNUM;
window.frames["BENFrame"].location.reload();
return 0;
}

</script>
</head>
<body>

<form name="WRSACTION" method="post" action="GETWRS2.asp">

<select name="GETWRS">
<option value="1234">1234</option>
<option value="12345">12345</option>
<option value="13456">13456</option>
<option value="14567">14567</option>
</select>
<input type="submit" value="Submit">
</form>
<iframe name="WRSFrame" height=150 width="100%" noresize="noresize" src=WRSFrame.asp></iframe>
<iframe name="CSRFrame" height=150 width="100%" noresize="noresize" src=CSRFrame.asp></iframe>
<iframe name="SAFrame" height=150 width="100%" noresize="noresize" src=SAFrame.asp></iframe>
<iframe name="BENFrame" height=150 width="100%" noresize="noresize" src=BENFrame.asp></iframe>
<%
Dim WRSNUM
Dim X
WRSNUM = Request.Form("GETWRS")
If Not(IsNull(WRSNUM)) AND Not(IsEmpty(WRSNUM)) Then
X = RefreshIFrames(CLng(WRSNUM))
End If
%>
</body>
</html>
My thinking on this was to use Javascript to do the refreshing and VBScript to pass the data. I would rather avoid Javascript as much as possible because of the web environment I'll be transferring functional code into, which will NOT be my PC, but a corporate environment. Unfortunately, nothing I've tried seems to allow me to get this to work. If I can get the Javascript function to be successfully called, the script fails on statements starting with either window. or document., or if not, I get a Type Mismatch error just trying to call the function. Btw, here is the code for the 1st IFrame, and the only difference between it and the rest of them is the text it outputs and it's filename. Also, I don't have any DTD statement, but I have no idea what effect that would have.


<html>
<head>
<title></title>
</head>
<body>
<%
Response.Write "THIS IS THE WRS FRAME, WRS NUMBER = "
Dim WRS
WRS = Request.QueryString("wrs")
If IsNull(WRS) Or IsEmpty(WRS) Then
WRS = "NULL"
End If
Response.Write WRS
%>
</body>
</html>
I've looked at the code suggested in post 22238 and I'm stymied at the moment by the type mismatch problem. I'm desperate to find a way to make this work, and if I'm just using the wrong approach, please let me know. I'm ESPECIALLY MOTIVATED to actually talk to someone on this, so please let me know if we can discuss by phone and I'll be glad to either provide the phone number or make the necessary call.

Steve
(aka sgmunson)
:confused: :confused: :confused:

sgmunson
10-20-2007, 01:28 AM
For a while, I was beginning to think that no one had ever managed to refresh an IFrame without either re-loading the main page or having a great deal more knowledge about ASP and Javascript than I might ever have. Despite massive searches on Google, I would only find code that might have worked for someone in the past, but clearly didn't work now, and of course, the post was at least 2 years old to begin with, or, it involved some technique that applied what might be common knowledge to an experienced web developer, but was couched in language only such a person would understand the details of. Anyway, to make a long story short, I finally did find some help and here is the basic method:


<head>
<title>MY PAGE</title>
<script type="text/javascript">
function RefreshIFrames(MyParameter)
{
document.all.FrameName.src="MyIFrameWebPage.asp?MyParm=" + MyParameter
}
</script>
</head>
<body>
<select name="MyDropDown" onchange="RefreshIFrames(this.options[selectedIndex].Value)">
<option value=1 "1" selected>
<option value=2 "2">
</select>
<iframe name="FrameName" application="yes" src="MyIFrameWebPage.asp">
</iframe>
</body>
</html>

My particular application ended up needing 5 IFrames, all of which do some ADODB work with a SQL Server data source, based on the passed parameter, which each IFrame source page gets from Request.QueryString. What a great improvement this represents for me over posting back to my main page.

Steve
(aka sgmunson)
:) :) :)