Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing Specific IFrames 1

Status
Not open for further replies.

BoulderBum

Programmer
Jul 11, 2002
2,179
US
How would I refresh a specific IFrame by name if I have, say, three IFrames in a page?
 
Code:
window.iframeName.location.reload()
or
Code:
window.iframeName.location.reload([url=http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/reload.asp?frame=true]true[/url]);
or
Code:
window.iframeName.location.href = window.iframeName.location.href;

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Thanks. Here's what I came up with:

Code:
function refreshFrames()
			{
				if( window.ifXml != null )
					window.ifXml.location.reload();
				if( window.ifHtml != null )
					window.ifHtml.location.reload();
				if( window.ifXslt != null )
					window.ifXslt.location.reload();
			}
...
<body onload="refreshFrames()">

I need to check for null because ASP.NET doesn't render the IFrames under certain conditions (can I check for null like that in JavaScript???).

I'm running into a problem, however. When the IFrames are rendered and the script presumably runs, it goes into an infinate loop or something (the hourglass just spins forever). Does the BODY Load() every time its child IFrames are refreshed or something?
 
I ran this little test to see if I got an infinite loop and I didn't.
Code:
<body onload="window.myI.location.reload()">
<iframe name="myI" src="test.html"></iframe>
</body>
Why are you reloading your Iframe right after it loads?

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Thanks again for the help.

"Why are you reloading your Iframe right after it loads?"

The IFrames reference xml/html pages on the server that are changed through actions on that page (after the page POSTs).

It works fine for the most part, but the XML/HTML in the IFrames don't always reflect the changes in the files unless I manually refresh the page.

Basically, I want to capture an event that fires every time the server sends back the response.

Is there a better way? I must admit that I'm a JavaScript newb.
 
I wondering now if part of the page (including IFrames) is being sent WHILE I'm saving the files, which may be the source of some of the issues.

I know this is a dumb question, but what do I have to do again to get a script to execute if I place it in the middle of my HTML (without attaching it to a control or page element)?
 
Well, if I understand your question, you can call your script as the page is loading by including this somewhere in the body.
Code:
<script>refreshFrames()</script>
You may have better luck disabling the browser's cache on the parent page and Iframe. You can do so by adding the following to the <head> tag:
Code:
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="-1">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
If you use ASP, you may want to use the following:
Code:
[COLOR=black yellow]<%[/color]
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
[COLOR=black yellow]%>[/color]

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Well, I was able to get the script executing when I wanted it to (with your help), but doing so was causing all sorts of goofy unpredictable problems. Oh well.

Thanks again, Adam.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top