Connecting Tech Pros Worldwide Forums | Help | Site Map

How to refresh a parent frame from a pop up?

nicver@yahoo.com
Guest
 
Posts: n/a
#1: Jul 23 '05
I am working on updating a Web site with a frameset. A page opens a
pop-up window in which the user uploads pictures. Once the upload is
done, I would like to refresh the content of the frame which opened the
pop-up but so far have failed. Here is my code:

<%

(ASP code which saves the photo in a database)

%>
<HTML>
<head>
<script language="javascript">
var url = top.parent.window.opener.document.all.MYURL.innerH TML +
'?ADID=<%=pintADID%>&MODE=S1&VIEWMODE=2';
top.parent.window.opener.location.href = url;
top.parent.window.close();
</script>
</head>
<body></body>
</html>


What I am trying to do is simply refresh the parent window with the
same URL. The ?ADID=<%=pintADID%>&MODE=S1&VIEWMODE=2' portion is there
to ensure that the browser does not refresh without the parameters.

Thanks a lot for your help!


Random
Guest
 
Posts: n/a
#2: Jul 23 '05

re: How to refresh a parent frame from a pop up?


nicver@yahoo.com wrote:[color=blue]
> I am working on updating a Web site with a frameset. A page opens a
> pop-up window in which the user uploads pictures. Once the upload is
> done, I would like to refresh the content of the frame which opened the
> pop-up but so far have failed. Here is my code:[/color]
....[color=blue]
> var url = top.parent.window.opener.document.all.MYURL.innerH TML +
> '?ADID=<%=pintADID%>&MODE=S1&VIEWMODE=2';
> top.parent.window.opener.location.href = url;
> top.parent.window.close();[/color]
....


Does the popup have a frameset?
If not, you could do this:

var url = (
opener.document.getElementById ?
opener.document.getElementById( 'MYURL' )
: opener.document.all.MYURL
).innerHTML + '?ADID=<%=pintADID%>&MODE=S1&VIEWMODE=2';

// if the location is already the url, just reload
if( opener.location.href == url )
opener.location.reload();

// otherwise, nagivate to said url
else
opener.location.href = url;

window.close();
[color=blue]
> </script>
> </head>
> <body></body>
> </html>
>
>
> What I am trying to do is simply refresh the parent window with the
> same URL. The ?ADID=<%=pintADID%>&MODE=S1&VIEWMODE=2' portion is there
> to ensure that the browser does not refresh without the parameters.[/color]

See above.

The code above is missing some compatibility checks for brevity's sake.

Also, in some circumstances it is a bad a idea to print the URL into
the page without first doing some translation of it. I don't know how
you're putting the URL in the page itself (i.e. whether you're building
the URL from scratch, doing any translation, or just dumping it into
the output), but be aware of any possible security considerations, as
this will allow users to essentially edit the code of the page that is
displayed and cause the browser to interpret the code in the context of
your domain name.

You may also want to check that the parent window is still relevant to
the popup, prior to trying to work with it.

Nicolas Verhaeghe
Guest
 
Posts: n/a
#3: Jul 23 '05

re: How to refresh a parent frame from a pop up?


Thanks. I am only taking over some sloppy development done prior to me. The
job is to get something to work, without reprogramming everything. The
client already spent a fortune for a Web site which does not function
properly.

I am not the best Javascript programmer out there, because I never really
spent a lot of time learning the compatibility issues.

Is this code MSIE-only? What would also work with Mozilla/Firefox and
Safari?

Thanks a lot for your help!

"Random" <randomiez@gmail.com> wrote in message
news:1117527070.185614.106250@g43g2000cwa.googlegr oups.com...[color=blue]
> nicver@yahoo.com wrote:[color=green]
>> I am working on updating a Web site with a frameset. A page opens a
>> pop-up window in which the user uploads pictures. Once the upload is
>> done, I would like to refresh the content of the frame which opened the
>> pop-up but so far have failed. Here is my code:[/color]
> ...[color=green]
>> var url = top.parent.window.opener.document.all.MYURL.innerH TML +
>> '?ADID=<%=pintADID%>&MODE=S1&VIEWMODE=2';
>> top.parent.window.opener.location.href = url;
>> top.parent.window.close();[/color]
> ...
>
>
> Does the popup have a frameset?
> If not, you could do this:
>
> var url = (
> opener.document.getElementById ?
> opener.document.getElementById( 'MYURL' )
> : opener.document.all.MYURL
> ).innerHTML + '?ADID=<%=pintADID%>&MODE=S1&VIEWMODE=2';
>
> // if the location is already the url, just reload
> if( opener.location.href == url )
> opener.location.reload();
>
> // otherwise, nagivate to said url
> else
> opener.location.href = url;
>
> window.close();
>[color=green]
>> </script>
>> </head>
>> <body></body>
>> </html>
>>
>>
>> What I am trying to do is simply refresh the parent window with the
>> same URL. The ?ADID=<%=pintADID%>&MODE=S1&VIEWMODE=2' portion is there
>> to ensure that the browser does not refresh without the parameters.[/color]
>
> See above.
>
> The code above is missing some compatibility checks for brevity's sake.
>
> Also, in some circumstances it is a bad a idea to print the URL into
> the page without first doing some translation of it. I don't know how
> you're putting the URL in the page itself (i.e. whether you're building
> the URL from scratch, doing any translation, or just dumping it into
> the output), but be aware of any possible security considerations, as
> this will allow users to essentially edit the code of the page that is
> displayed and cause the browser to interpret the code in the context of
> your domain name.
>
> You may also want to check that the parent window is still relevant to
> the popup, prior to trying to work with it.
>[/color]


Random
Guest
 
Posts: n/a
#4: Jul 23 '05

re: How to refresh a parent frame from a pop up?


So far as I know it should work in most relatively modern browsers.
Expect compatibility issues with older versions of Netscape that few
people still use, and probably other older, less-used agents.



Nicolas Verhaeghe wrote:[color=blue]
> Thanks. I am only taking over some sloppy development done prior to me. The
> job is to get something to work, without reprogramming everything. The
> client already spent a fortune for a Web site which does not function
> properly.
>
> I am not the best Javascript programmer out there, because I never really
> spent a lot of time learning the compatibility issues.
>
> Is this code MSIE-only? What would also work with Mozilla/Firefox and
> Safari?
>
> Thanks a lot for your help!
>
> "Random" <randomiez@gmail.com> wrote in message
> news:1117527070.185614.106250@g43g2000cwa.googlegr oups.com...[color=green]
> > nicver@yahoo.com wrote:[color=darkred]
> >> I am working on updating a Web site with a frameset. A page opens a
> >> pop-up window in which the user uploads pictures. Once the upload is
> >> done, I would like to refresh the content of the frame which opened the
> >> pop-up but so far have failed. Here is my code:[/color]
> > ...[color=darkred]
> >> var url = top.parent.window.opener.document.all.MYURL.innerH TML +
> >> '?ADID=<%=pintADID%>&MODE=S1&VIEWMODE=2';
> >> top.parent.window.opener.location.href = url;
> >> top.parent.window.close();[/color]
> > ...
> >
> >
> > Does the popup have a frameset?
> > If not, you could do this:
> >
> > var url = (
> > opener.document.getElementById ?
> > opener.document.getElementById( 'MYURL' )
> > : opener.document.all.MYURL
> > ).innerHTML + '?ADID=<%=pintADID%>&MODE=S1&VIEWMODE=2';
> >
> > // if the location is already the url, just reload
> > if( opener.location.href == url )
> > opener.location.reload();
> >
> > // otherwise, nagivate to said url
> > else
> > opener.location.href = url;
> >
> > window.close();
> >[color=darkred]
> >> </script>
> >> </head>
> >> <body></body>
> >> </html>
> >>
> >>
> >> What I am trying to do is simply refresh the parent window with the
> >> same URL. The ?ADID=<%=pintADID%>&MODE=S1&VIEWMODE=2' portion is there
> >> to ensure that the browser does not refresh without the parameters.[/color]
> >
> > See above.
> >
> > The code above is missing some compatibility checks for brevity's sake.
> >[/color][/color]

Closed Thread