Solved

Refreshing the Frame

Posted on 2006-11-26
19
417 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:aspnetdev
  • 10
  • 6
  • 3
19 Comments
 
LVL 3

Expert Comment

by:viveksg
ID: 18017386
If you want to execute the javascript, you better write

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

and keep the function refreshCont() in your js file.
0
 
LVL 6

Expert Comment

by:aescnt
ID: 18017388
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?
0
 
LVL 3

Expert Comment

by:viveksg
ID: 18017395
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>");
0
 

Author Comment

by:aspnetdev
ID: 18017402
yep thts server side
0
 

Author Comment

by:aspnetdev
ID: 18017422
Viveksg ..i get the same error...ur solution does not work
0
 
LVL 3

Expert Comment

by:viveksg
ID: 18017506
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';
0
 

Author Comment

by:aspnetdev
ID: 18017519
frames['content'] is the name of frame
0
 
LVL 6

Expert Comment

by:aescnt
ID: 18017545
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. :)
0
 

Author Comment

by:aspnetdev
ID: 18019483
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
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:aspnetdev
ID: 18019707
i also tried
opener.frames['content'].location='../Welcome.aspx'
but same error
0
 
LVL 6

Expert Comment

by:aescnt
ID: 18019743
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.
0
 

Author Comment

by:aspnetdev
ID: 18019760
but if i debug it ....i breaks at window.parent.frames['content'].location  and gives the error.
0
 
LVL 6

Expert Comment

by:aescnt
ID: 18019780
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?
0
 

Author Comment

by:aspnetdev
ID: 18019829
<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>
0
 

Author Comment

by:aspnetdev
ID: 18019837
actually its a pop up window...in where if EChanged or Cchanged then the parent page content frame should be redirected to welcom.aspx
0
 
LVL 6

Expert Comment

by:aescnt
ID: 18019895
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?
0
 
LVL 6

Accepted Solution

by:
aescnt earned 500 total points
ID: 18019943
...If that's the case, try window.opener.top.frames['content'].location.
0
 

Author Comment

by:aspnetdev
ID: 18019971
...i did that too aescnt....man this is really gettin on my nerves....dont understand whts the pbm
0
 

Author Comment

by:aspnetdev
ID: 18020058
kool it works aescnt ...actually  i was forgetting to put window
--Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now