Link to home
Start Free TrialLog in
Avatar of aspnetdev
aspnetdev

asked on

Refreshing the Frame

Hi,
I have the following javascrpt where i have to refresh my Middle frame on condition.im using the following script but its giving error

 string refreshContentJS;
refreshContentJS = "<script src='../../Scripts/Helper.js'></script>";
if (CChanged || EChanged)
{
  refreshContentJS += "<script>refreshCont()</script>";  
}
Response.Write(refreshContentJS);

and the helper.js has following fucntion...

function refreshCont () {
      window.parent.frames['content'].location = '../Welcome.aspx';
}

im getting following error

window.parent.frame.content is null or not an object.

i just want to redirect the content frame to welcome.aspx on tht "if " condition...can anhyone help me out.urgent
thanks
Avatar of viveksg
viveksg

If you want to execute the javascript, you better write

RegisterStartupScript("key","<script>refreshCont()</script>");

and keep the function refreshCont() in your js file.
is "window.parent.frame.content is null or not an object." the error message in verbatim? if so, then the error is not in the script you gave, it might be somewhere else where "window.parent.frame.content" is referenced. Is the first snippet a server-side JScript, by the way?
To be more clear,

HTML
====
<head>
<script src='../../Scripts/Helper.js'></script>
<script>
function refreshCont () {
     window.parent.frames['content'].location = '../Welcome.aspx';
}
</script>
</head>

CODE-BEHIND
=========
RegisterStartupScript("key","<script>refreshCont()</script>");
Avatar of aspnetdev

ASKER

yep thts server side
Viveksg ..i get the same error...ur solution does not work
try giving the frame number.

like if you have top frame, left frame and middle frame, and you are trying to change the middleframe from left frame, then give window.parent.frames[2].location = '../Welcome.aspx';
frames['content'] is the name of frame
frames['content'] should suffice if the parent page has a frame named "content." Kind of a blind guess here, but maybe it's not the topmost frame; you can try window.top.frames['content'].location. :)
That does not work either....i tried this and still i get the error   window.parent.frame.content is null or not an object.


if (CChanged || EChanged)
{
     Response.Write("<script>window.parent.frames['content'].location='../Welcome.aspx';</script>");
}

where content is the name of the frame where all pages are displayed...urgent help wud be appreciated ..thanks
i also tried
opener.frames['content'].location='../Welcome.aspx'
but same error
If you get the "same" error, i.e., "window.parent.frame.content is null or not an object", perhaps it's saying that we're fixing the wrong thing.
but if i debug it ....i breaks at window.parent.frames['content'].location  and gives the error.
Maybe this can help you debug:

if (!window.parent) { alert("There is no parent.");
if (!window.parent.frames) { alert("There is no frames in this window's parent.");
var frms = '';
for (var i in window.parent.frames) { frms += i + '/'; }
alert("The frames of the parent window are: " + frms);

Also, may we see your <framset><frame...></frameset> code?
<frameset rows="64,86%,17" framespacing="0" frameborder="0">
<frame name="topFrame" style="CURSOR: n-resize; BORDER-BOTTOM: black 1px solid" scrolling="no"
                  noresize src="top.aspx">
<frameset cols="166,83%">
<frame name="left-frame" style="BORDER-RIGHT: #000000 1px solid; CURSOR: e-resize" target="right-frame"
                        src="menu.aspx">
<frame name="content" DESIGNTIMEDRAGDROP="10" src="Welcome.aspx" >
</frameset>
<frame name="bottom-frame" style="BORDER-TOP: #000000 1px solid; CURSOR: n-resize" scrolling="no"
                  target="right-frame" src="bottom.aspx" DESIGNTIMEDRAGDROP="574">
</frameset>
actually its a pop up window...in where if EChanged or Cchanged then the parent page content frame should be redirected to welcom.aspx
So let me get this -- the frame page contains top.aspx/menu.aspx/welcome.aspx/bottom.aspx -- and then one of these pages calls a popup window, that contains the code in your question?
ASKER CERTIFIED SOLUTION
Avatar of aescnt
aescnt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
...i did that too aescnt....man this is really gettin on my nerves....dont understand whts the pbm
kool it works aescnt ...actually  i was forgetting to put window
--Thanks