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!

Window.open Asp.net wierd problem

Status
Not open for further replies.

Kshoot

Programmer
Jun 23, 2004
7
US
Below is the code.

language = asp.net/vb.net

private sub openW()

sResult = sResult & "<script language=javascript> mywindow = window.open(' "

sResult = sResult & "mywindow.parent.frames[1].location = ' "

sResult = sResult & "mywindow.parent.frames[0].location = ' </script>"

Response.Write(sResult)

End Sub

I am calling this in LinkButton(asp.net servercontrol) Click event

it opens the new window and the new window has got the frames with in frames and frames with in those frames.

the above code works fine on local boxes and once the code is pushed to server(testing box), it works for 1st time and then on it stops working and i get a message "mywindow.parent.frames.1 is null or not a object error".

while pushing the localhost is made to the respective box name.

i cannot imagine a reason for working once and not working again., if anyone recall the same error before and have fixed please let me know?

any help is appriciated

Kshoot
 

You need to ensure that the frameset is loaded before you can set properties on the frames. Suggest you have an "onload" method on your frameset which calls a callback function on your source page, which then can set the frame properties without causing an error.

Hope this helps,
Dan
 
how can i track the new window frameset is loaded or not, i am assuming and loading the frameset with the appropriate page into the frame.

Kshoot
 

>> how can i track the new window frameset is loaded or not

I already told you that - have an onload event call in your frameset page.. Something like this:

Code:
<frameset onload="framesetLoaded();">

and then have a some javascript in your frameset with a function to match:

Code:
function framesetLoaded() {
    if (window.opener != null) window.opener.myCallBackFunction();
}

Which should call the callback function named "myCallBackFunction" in your opener document.

When that is called, you know it is safe to address all frames within the frameset.

Hope this helps,
Dan
 
Billy,
let me explain the question properly.

i have a page1, where i am writing the above(first post) code, i dont have any control of the page iam opening page2, i only know that that page has got the frames and what my code should do is drop the appropriate aspx pages into it.

now how can i get to know that the page2's frameset is loaded from page1.

sorry if iam buggin you


 

OK - if you have no control over the frameset, then you cannot do what I have described. Possibly the only thing you could do would be to test for the presence of each frame before trying to set its source, although having said that - if you don't have control over the frames, due to JS security, you may not be able to do even this.

You might be able to test for the presence of a frame by using something like this:

Code:
if (mywindow.parent.frames[1]) // do stuff here

Failing that, I'm out of ideas ;o)

Dan
 
that trick still doesnot work, but good thing is i stop getting the message(alert box) atleast that was good.

one thing i dunno you have noticed or not in my first post, it works first time and then on it stops working in testing box the same works perfectly on the local boxes though. I cannot imagine a reason for that.

may be you can shed more light on the Webserver side, putting aside the javascript side, since we know that code is right?

kshoot

 
can anyone take a look at this problem again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top