[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2147
  • Last Modified:

How to redirect in page opened by showModalDialog - so that the page will appear in the same window

Hi,

I use showModalDialog(url1 ...)

if in page with url1 I  use document.location=url2 - url2 is opened in the different window. How to cause to open in the same window?
0
netformx
Asked:
netformx
  • 8
  • 5
  • 2
1 Solution
 
archrajanCommented:

by
using the showModalDialog with the 2nd url and the same name as the first window!
0
 
Michel PlungjanIT ExpertCommented:
Use a frameset in the modal
0
 
netformxAuthor Commented:
thanks
calling showModalDialog  works fine, but the problem is that it's good only if url2 was opened by showModalDialog as well.

The question is: in url2 can I know if it was opened by showModalDialog or window.open?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
archrajanCommented:
url2 is loaded in modaldialog right?
0
 
netformxAuthor Commented:
There was mistake in my question (sorry): The question is: in url1 (!!!) can I know if it was opened by showModalDialog or window.open?


url1 is sometimes loaded by using showModalDialog  and sometimes by window.open

If I understand correct:
if it's loaded by showModalDialog   - it should redirect to url2 by calling showModalDialog , if it's lded by window.open - it redirects by using document.location.

Unless, you can suggest solution that will work (=the page will be displayed in the same window)in both cases , no matter how it was loaded
0
 
Michel PlungjanIT ExpertCommented:
page to open in showmodal

<frameset rows="100%,*">
<frame src="url1.html">
</frameset>


in the page:

if (top.dialogArguments) alert('I am opened by a showmodal')

However since you are now in a frameset, any window.location=url2
will  work regardless
0
 
netformxAuthor Commented:
could you, pelase be more specific?

let's give names:
from url0 - I want to open url1 in modal window
from url1 I want to open url2 in the same window

so where do I insert the frameset?
0
 
Michel PlungjanIT ExpertCommented:
in url0

<script>
showModalDialog('myframeset.html')
</script>

in myframeset.html:


<frameset rows="100%,*">
<frame src="url1.html">
</frameset>

in url1.html:

<a href="#" onClick="window.location='url2.html'; return false">URL2</a>

or just

<a href="url2.html">URL2</a>


If the url of url1 is variable you can do this:

in url0

<script>
url1='URL1.html'
if (window.showModalDialog) showModalDialog('myframeset.html',window)
else window.open('myframeset.html','newwin')
</script>

in myframeset.html:


<frameset rows="100%,*" onLoad="if (top.dialogArguments && top.dialogArguments.url1)
loc = top.dialogArguments.url1;
else if (top.opener && top.opener.url1) loc=top.opener.url1;
top.frames[0].location.replace(loc)">
<frame src="javascript:' '">
</frameset>
0
 
netformxAuthor Commented:
If I put

<frame src="url1.aspx"> - url1 is not displayed. Is it supposed to work with aspx pages?
0
 
Michel PlungjanIT ExpertCommented:
sure...

How does the rest of the page look?
0
 
netformxAuthor Commented:
I udnerstood what was teh issue with aspx: frameset has to be aspx as well.

but: url1.aspx had GET params (as you said it's a varible: url1.aspx?val=kuku

If so - Have I use your second way? (with dialogArguments) if so, it does not work .... I addd var before loc (since it said that loc is not defined and now frameset is opened but the url1 is not ....)
0
 
netformxAuthor Commented:
the probl;em is that top.dialogArguments.url1 is undefined!!! although I did define it's in url0:
var url1="...";

any idea????
0
 
netformxAuthor Commented:
I figured out what was the problem - testing it now ....
0
 
netformxAuthor Commented:
it works fine, thanks!
0
 
Michel PlungjanIT ExpertCommented:
:)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 8
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now