Showmodaldialog & refresh parent

Hi there,

I have created a frame that will display the information I want in a showmodaldialog box, so I can use links and forms without it being opened up in a new window.

What im using it for is to set users preferences, and when the user closes the box I need the parent window to be refreshed so that the settings take effect.

Can someone help?

Gav

window.onunload = refresh;

funtion refresh()
{
    opener.getElementById("someID").style.color =
               document.getElementById("IDonthispage").value;
}
</script>
</head>

This won’t work because its showmodaldialog(); I need to be able to just refresh the page that opened it.

Do you know how I can call the page? So if I told it window.name = “test”; on the page I want to refresh, would I be able to refresh it somehow. I’ve tried doing that and then calling window.test.reload(); but it can’t find the page.

Anything else?

Hmm…I didn’t realize a modal dialog window didn’t have an opener property.

So if I told it window.name = “test”; on the page I want to refresh, would I be able to refresh it somehow. I’ve tried doing that and then calling window.test.reload(); but it can’t find the page.
A reference to an element is known as a ‘pointer’ in C++, and it is a numbered location in memory where the html element is located. So, a reference is a number. What you need to do is get that number–you can think of it as a secret code.

A string like “test” is not a reference/number–it’s a string. It’s the same old story. You have to repeat three times before you go to bed every night: “a string is not a reference, a reference is a number, so if I have a string, it’s not a reference.”

What you need to do is pass the main window’s secret code to the dialog window. You can do that using the second parameter of showModalDialog():

main page:

var window_ref = window;
showModalDialog("my_dialog_page.htm", [COLOR=Red]window_ref[/COLOR], "dialogHeight:200px;dialogWidth:200px;dialogLeft:100px;dialogRight:100px;");

Then, you can retrieve that secret code with js in the dialog window, and use the secret code to change the main window. The secret code you passed will be contained in the .dialogArguments property of the dialog window:

window.dialogArguments

So, you can do something like this to change the main page:

window.dialogArguments
.document.getElementById(“my_div”).style.backgroundColor=“red”;

right…

what I have is a normal html page which is like this… then the user clicks on an options button, this then opens a showmodaldialog, the page that is opened, has framing scripted, and I have basically used asp to fool it, so I use Iframe.asp to show in the box, then top of the frame is iframe.asp?url=about:blank and the bottom is iframe.asp?url=options.asp.

Now when the user has selected their viewing options they click close ( either my button or the x ) now when they do that I want to use the onUnload function to refresh the page that opened it. So that the options selected take effect.

Now I can use window.close to close the dialog window, even though it’s inside a frame, which I was supprised.

But how would I be able to refresh the page? Do you know?

apologies, I read your post wrong 7stud…

tried it and it worked great, so I changed it to

window.dialogArguments.document.history.go(0); and now it refreshes the parent page… added window.close(); on the end and einstien solved the problem…

Thanks again mate!

Gav