Solved

Refreshing the Frame

Posted on 2006-11-26
19
419 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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
 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

830 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