HTML Code ClinicDo you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
Ok, here's a fun one. This question is really two fold.
#1, I have a pop-up submit window. I want to user to fill out that form and hit the submit button. When they hit that submit button, it will close the pop-up window (javascript:window.close()) and refresh the parent window. (javascript:window.refresh()) So how do I tell the pop-up to refresh the parent? I can get it to refresh itself, just not refresh the parent.
#2, Imagine this: There's a textbox with a drop-down menu just below it. I want the user to type things in the textbox, then select something from the dropdown and be able to add it to the textbox automatically by clicking on a link.. Say "insert"? That link will insert the value of the dropdown at the location of their cursor. Any ideas?
For your first problem:
To change the location/refresh the parent window you can use the opener property.
This one will change the href of the parent from the pop-up.
window.opener.location.href = the_url;
The reload method will work too,
This does a hard reload (returns forms to default values)
The optional boolean conditional argument will if true make a new request of the server, if false it will attempt to pull the page from the cache.
window.opener.location.reload(true);
If you want to preserve form data (soft reload), use the history method.
window.opener.history.go(0);
'0' causes the page to reload, a negative value represents how many steps backward you'd like to go.
function addListboxValue()
{
var oLst = document.getElementById("lstCountries");
var oTxt = document.getElementById("txtTown");
oTxt.value += oLst.options[oLst.selectedIndex].text;
}
for window.showModalDialog, we can use this also:
window.dialogArguments.location = window.dialogArguments.location;
(to avoid messagebox asking for Retry and Cancel with the message : "The page cannot be refreshed without resending the information again. Click Retry to resend the information. CLick Cancel.... ")
I am facing the same probelm, can you please help me out?
Here is my code.
Following code is to open popup window:
function OpenInstitutions(sURL)
{
var newwindow;
newwindow = window.open(sURL,"Institutions","toolbar=no,locati on=no,scrollbars=yes,statusbar=no,height=600,width =870,resizable=yes");
if (window.focus) {
newwindow.focus()
}
}
Following code is to close popup and refresh parent and focus.
function SaveSetting()
{
alert("Settings have been saved successfully.");
var url = "CalInstitutions.aspx";
opener.location.reload(true);
//opener.history.go(0);
opener.focus();
self.close();
}
The above is working, but it is showing following alert message in parent window.
"The page cannot be refreshed without resending the information again. Click Retry to resend the information. CLick Cancel.... ".
Hi I have a popup on popup close i am refreshing parent page but it is giving msgbox and when i click on retry then only my page is refreshed, is there any other way to refresh parent page.