?
Solved

showModelessDialog issues

Posted on 2003-03-04
12
Medium Priority
?
2,692 Views
Last Modified: 2007-12-19
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>
0
Comment
Question by:jzeil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 5

Expert Comment

by:gator4life
ID: 8070192
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)
0
 
LVL 1

Expert Comment

by:Commodus2
ID: 8071409
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 :)
0
 
LVL 5

Expert Comment

by:gator4life
ID: 8072160
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)
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:jzeil
ID: 8072716
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
0
 
LVL 1

Accepted Solution

by:
Commodus2 earned 200 total points
ID: 8072809
You can use a window.open() intead of a dialog
here you can do whatever you want with links and everything, because it is a normal page. And to prevent that the users will click along side the popup to get back without closing the popup, you can add (a little dirty) onblur="this.focus();" to the <body of the popup window

so you get this:
function openWindow(){
 window.open("foo.html");// you can add props for the window. see msdn for details on window.open
}

and in the foo.html:

<html>
<body onblur="this.focus();" >
...
</body>
</html>

I hope this is something you had in mind.
0
 
LVL 1

Expert Comment

by:Commodus2
ID: 8072855
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
0
 

Author Comment

by:jzeil
ID: 8072977
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
0
 

Author Comment

by:jzeil
ID: 8073058
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
0
 

Author Comment

by:jzeil
ID: 8073269
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
0
 

Author Comment

by:jzeil
ID: 8073275
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
0
 

Author Comment

by:jzeil
ID: 8074571
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
0
 

Expert Comment

by:joelfinch
ID: 8500121
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
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…
Suggested Courses

771 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