dotolee
05-20-2011, 02:28 PM
I have a CLASSIC ASP in IE 8 that is using the winhttprequest object to get the contents of an "external" website (just a page from another department here.. but a different server).Then i modify the html i get to suit my needs.. save it to a file, and then finally, i display this stuff in an IFRAME. (i wrapped a div tag around the iframe so technically, i'm doing something like: "divtabframe.innerHTML = '<IFRAME SRC='myserver/somepage.html'></IFRAME>)
My problem is that when i refresh the main page, i want the iframe to also display the latest data. It does get the latest data from the external site and its saved in "somepage.html". But the iframe isn't updated unless i explicitly right-click inside the frame and manually select refresh. I have added a <meta http-equiv="refresh" content="30"> line to make it auto refresh on it's own. But the users find it annoying that the page refreshes while they're working on it. They prefer to have their own button that will refresh both the main page that gets the data, and the iframe to read the new file.
So far, I've been trying to see if i can get the iframe to refresh when the users click on the tab "buttons". But i'm getting an error that says:
"'document.getElementById(...).contentDocument.location' is null or not an object "
on the line where I'm trying to reload the iframe. (in bold italics below)
So... here's some snippets from my code.First thing i do before displaying anything is i get the data i need for the iframe from an external server. It creates a file on my local server.
<%
GetLOData("maint")
GetLOData("hc")
%>
<HTML>
<HEAD>
<script type="text/javascript">
var tabs = new Array(
"Tab 1 Title|http://myserver/Dev/s/tab1.html|*",
"'Tab 2 Title'|http://myserver/Dev/s/tab2.html",);
// Align Tab: LEFT, CENTER, RIGHT
var tabAlign = "LEFT";
function tabOnClick(ID){
var oElement = null;
for (var i = 0; i < tabs.length; i++)
{
oElement = document.getElementById(i);
oElement.className = "tabOff";
}
oElement = document.getElementById(ID);
oElement.className = "tabOn";
var tab = tabs.split("|");
divTabFrame.innerHTML = "<IFRAME SRC="+tab[1]+" ID=iframe"+ID+ " CLASS='tabFrame'></IFRAME>";
[I]document.getElementById("iframe"+ID).contentDocument.location.reload(true);
document.body.focus();
}
function tabLoad(){
var HTML = "";
HTML += "<P ALIGN="+tabAlign+">";
for (var i = 0; i < tabs.length; i++)
{
var tab = tabs[i].split("|");
HTML += "<INPUT TYPE='BUTTON' ID="+i+" CLASS='tabOff' VALUE="+tab[0]+" onClick='tabOnClick("+i+")'> ";
}
divTabButtons.innerHTML = HTML;
for (var i = 0; i < tabs.length; i++)
{
var tab = tabs[i].split("|");
if (tab[2] == "*")
{
tabOnClick(i);
break;
}
}
}
</script>And then later on, here's my code to display the iframe with divs.
<TR>
<TD colspan="3" align="left">
<BR>
<DIV ID="divTabButtons"></DIV>
<DIV ID="divTabFrame"></DIV>
</TD>
</TR>
I tried changing "document.getElementById
("iframe"+ID).contentDocument.location.reload(true); "
to
"document.getElementById("iframe"+ID).contentWindow.location.reload(true); "
but that didn't resolve my problem either. I also tried reloading the div tag that wraps around the frame instead.. but i get the same error message.
can someone either:
help me figure out what's wrong with my call to the .reload on the iframe, or tell me another way to refresh both pages at the same time?
Thanks for reading this post.
My problem is that when i refresh the main page, i want the iframe to also display the latest data. It does get the latest data from the external site and its saved in "somepage.html". But the iframe isn't updated unless i explicitly right-click inside the frame and manually select refresh. I have added a <meta http-equiv="refresh" content="30"> line to make it auto refresh on it's own. But the users find it annoying that the page refreshes while they're working on it. They prefer to have their own button that will refresh both the main page that gets the data, and the iframe to read the new file.
So far, I've been trying to see if i can get the iframe to refresh when the users click on the tab "buttons". But i'm getting an error that says:
"'document.getElementById(...).contentDocument.location' is null or not an object "
on the line where I'm trying to reload the iframe. (in bold italics below)
So... here's some snippets from my code.First thing i do before displaying anything is i get the data i need for the iframe from an external server. It creates a file on my local server.
<%
GetLOData("maint")
GetLOData("hc")
%>
<HTML>
<HEAD>
<script type="text/javascript">
var tabs = new Array(
"Tab 1 Title|http://myserver/Dev/s/tab1.html|*",
"'Tab 2 Title'|http://myserver/Dev/s/tab2.html",);
// Align Tab: LEFT, CENTER, RIGHT
var tabAlign = "LEFT";
function tabOnClick(ID){
var oElement = null;
for (var i = 0; i < tabs.length; i++)
{
oElement = document.getElementById(i);
oElement.className = "tabOff";
}
oElement = document.getElementById(ID);
oElement.className = "tabOn";
var tab = tabs.split("|");
divTabFrame.innerHTML = "<IFRAME SRC="+tab[1]+" ID=iframe"+ID+ " CLASS='tabFrame'></IFRAME>";
[I]document.getElementById("iframe"+ID).contentDocument.location.reload(true);
document.body.focus();
}
function tabLoad(){
var HTML = "";
HTML += "<P ALIGN="+tabAlign+">";
for (var i = 0; i < tabs.length; i++)
{
var tab = tabs[i].split("|");
HTML += "<INPUT TYPE='BUTTON' ID="+i+" CLASS='tabOff' VALUE="+tab[0]+" onClick='tabOnClick("+i+")'> ";
}
divTabButtons.innerHTML = HTML;
for (var i = 0; i < tabs.length; i++)
{
var tab = tabs[i].split("|");
if (tab[2] == "*")
{
tabOnClick(i);
break;
}
}
}
</script>And then later on, here's my code to display the iframe with divs.
<TR>
<TD colspan="3" align="left">
<BR>
<DIV ID="divTabButtons"></DIV>
<DIV ID="divTabFrame"></DIV>
</TD>
</TR>
I tried changing "document.getElementById
("iframe"+ID).contentDocument.location.reload(true); "
to
"document.getElementById("iframe"+ID).contentWindow.location.reload(true); "
but that didn't resolve my problem either. I also tried reloading the div tag that wraps around the frame instead.. but i get the same error message.
can someone either:
help me figure out what's wrong with my call to the .reload on the iframe, or tell me another way to refresh both pages at the same time?
Thanks for reading this post.