Avatar of jzeil
jzeil
 asked on

showModelessDialog issues

I'm using IE's showModelessDialog command and I am at a loss on how to use these things ( have yet to find a good resource) hopefully you can help.

I have two problems that I need solving.
1. When I click on a link in the modelessDialog it opens the link in a NEW window so now I have 3 windows (the parent, the modeless one and this new one).  I want the link to open in the modelessDialog
2.How can I make the modeless dialog refresh the parent when you close it?

Main.html
-------------------------
<html>
<head>
<title>Main</title>

<script language="Javascript1.2">
function modelesswin(url,mwidth,mheight){
    eval('window.showModelessDialog(url,window,"help:0;resizable:1;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")')
}
</script>

</head>
<body>
<SCRIPT>
document.write(Date()+".")
</SCRIPT>

<br><br>
This is the main page.<br><br>
<a href="javascript:modelesswin('popup.html', 300, 300)">Click here</a> to open a modal window
</body>
</html>

popup.html
----------------------
<html>
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

<title>Popup</title>
<script language="JavaScript1.2">

function refreshMain(){
//CODE HERE
}

</script>

</head>
<body>
This is the popup page.<br><br>

<a href="javascript:refreshMain();">Click here</a> close this window and refresh the main window.
<br><br>
<a href="http://www.cnn.com">Click here</a> load something new in this window.

</body>
</html>
JavaScript

Avatar of undefined
Last Comment
joelfinch

8/22/2022 - Mon
gator4life

Here are the answers to your questions:

(1) You cannot navigate the modeless dialog window.  The URL that you open in the modeless dialog is the only URL that can appear in it.

(2) To have the main window refresh when the modeless dialog is closed, you need to add the following line of code into the refreshMain() function:

          function RefreshMain() {
               window.dialogArguments.location.reload();
          }

Then, since you can't navigate the modeless dialog window, you cannot use an <a></a> object's "href" property to call the function through the javascript protocol.  You have to unfortunately use the onclick event handler of the <input type="button"> object:

          <input type="button" value="Refresh Main Window" onclick="refreshMain()">

Hope this helps.  Let me know if you have any other questions.

gator4life
(chomp, chomp)
Commodus2

To add to what gator said:
If you use a input type=button you require a form.

If you use <button onClick="refreshMain()">Close</button>
you dont need a form.

although i think IE will accept a input button without a form... a well... your document will be well formed :)
gator4life

Commodus2 is correct.  You *should* put the <input type="button"> inside of a <form></form>, if you want your HTML to be well-formed.  However, since the showModelessDialog() method is *only* available to IE, and IE does not care whether you use the <form></form> or not, the decision is entirely up to you.  I suggest you use it though, since I am a big supporter of well-formed HTML.

gator4life
(chomp, chomp)
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
jzeil

ASKER
With the knowledge that you cannot navigate a modeless dialog window my question changes slightly (since I still havent solved my problem).

Can I have a window that I can navigate which also will always stay on top of the parent page. Above, gator4life, states that I cannot do this with a modeless dialog window.  Is their something avaiable that will allow me to do this?

Or can I use a modeless dialog window and submit forms on it which refresh IT.

Some context to my problem.  I'm working on a web application where users can customize settings in a popup dialog. Ideally they would change settings in the dialog, which would then refresh itself. Once they are finished working in the dialog I would like the main page to refresh on the onclose event of the dialog.  I would *like* to use a dialog that stays on top of the main page, since i find it more user friendly (you dont have to worry about the dialog getting lost behind the browser window).

Thanks for your help... I feel im  getting closer to an answer even if it isnt exactly what i want.

Also, could you please send a good resource about this modeless dialog stuff.  No where did I find it mentioned that these things were not navigatible.

Jack
ASKER CERTIFIED SOLUTION
Commodus2

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Commodus2

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/showmodelessdialog.asp

this is the official documentation.. in cas you haven't found that. I agree with you that it is not very clear that you cannot navigate thru these dialogs
jzeil

ASKER
With the knowledge that you cannot navigate a modeless dialog window my question changes slightly (since I still havent solved my problem).

Can I have a window that I can navigate which also will always stay on top of the parent page. Above, gator4life, states that I cannot do this with a modeless dialog window.  Is their something avaiable that will allow me to do this?

Or can I use a modeless dialog window and submit forms on it which refresh IT.

Some context to my problem.  I'm working on a web application where users can customize settings in a popup dialog. Ideally they would change settings in the dialog, which would then refresh itself. Once they are finished working in the dialog I would like the main page to refresh on the onclose event of the dialog.  I would *like* to use a dialog that stays on top of the main page, since i find it more user friendly (you dont have to worry about the dialog getting lost behind the browser window).

Thanks for your help... I feel im  getting closer to an answer even if it isnt exactly what i want.

Also, could you please send a good resource about this modeless dialog stuff.  No where did I find it mentioned that these things were not navigatible.

Jack
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
jzeil

ASKER
With the knowledge that you cannot navigate a modeless dialog window my question changes slightly (since I still havent solved my problem).

Can I have a window that I can navigate which also will always stay on top of the parent page. Above, gator4life, states that I cannot do this with a modeless dialog window.  Is their something avaiable that will allow me to do this?

Or can I use a modeless dialog window and submit forms on it which refresh IT.

Some context to my problem.  I'm working on a web application where users can customize settings in a popup dialog. Ideally they would change settings in the dialog, which would then refresh itself. Once they are finished working in the dialog I would like the main page to refresh on the onclose event of the dialog.  I would *like* to use a dialog that stays on top of the main page, since i find it more user friendly (you dont have to worry about the dialog getting lost behind the browser window).

Thanks for your help... I feel im  getting closer to an answer even if it isnt exactly what i want.

Also, could you please send a good resource about this modeless dialog stuff.  No where did I find it mentioned that these things were not navigatible.

Jack
jzeil

ASKER
With the knowledge that you cannot navigate a modeless dialog window my question changes slightly (since I still havent solved my problem).

Can I have a window that I can navigate which also will always stay on top of the parent page. Above, gator4life, states that I cannot do this with a modeless dialog window.  Is their something avaiable that will allow me to do this?

Or can I use a modeless dialog window and submit forms on it which refresh IT.

Some context to my problem.  I'm working on a web application where users can customize settings in a popup dialog. Ideally they would change settings in the dialog, which would then refresh itself. Once they are finished working in the dialog I would like the main page to refresh on the onclose event of the dialog.  I would *like* to use a dialog that stays on top of the main page, since i find it more user friendly (you dont have to worry about the dialog getting lost behind the browser window).

Thanks for your help... I feel im  getting closer to an answer even if it isnt exactly what i want.

Also, could you please send a good resource about this modeless dialog stuff.  No where did I find it mentioned that these things were not navigatible.

Jack
jzeil

ASKER
doh! Sorry guys for the repostings.... I was just refreshing this page to see if there were responses.... Looks like it kept submitting the question
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
jzeil

ASKER
well I was hoping to use some cool feature of IE but hacking a normal window so when it blurs you just give it focus works just as well. Thanks
joelfinch

You can workaround the issue of navigation in a modeless dialog by using a frameset in the dialog.

Make a frameset with two rows, one 100%, and the other 0, and turn off all the frame borders. Use the page you actually want to display as the src for the 100% frame (you can use "about:blank" as the src for the other).

This will look like just a single page, and any normal <a> links will be able to load into the same frame.

This way, the top-level page doesn't change, which satisfies the modelessdialog security rules preventing navigation, and you get all the other benefits of the real modeless dialog.

And since you can't bookmark or right-click in a modeless dialog anyway, there's none of the usual disadvantages of frames.

Hope that's of some help,

- Joel