Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

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>
0
jzeil
Asked:
jzeil
  • 6
  • 3
  • 2
  • +1
1 Solution
 
gator4lifeCommented:
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
 
Commodus2Commented:
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
 
gator4lifeCommented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jzeilAuthor Commented:
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
 
Commodus2Commented:
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
 
Commodus2Commented:
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
 
jzeilAuthor Commented:
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
 
jzeilAuthor Commented:
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
 
jzeilAuthor Commented:
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
 
jzeilAuthor Commented:
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
 
jzeilAuthor Commented:
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
 
joelfinchCommented:
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 6
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now