Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh popup (javascript)

Status
Not open for further replies.

DrStern

Programmer
Mar 28, 2003
53
US
Hello everybody,

I have a popup window that it is being opened by a parent one. My popup is supposed to be refreshed if the user changes something on it. That is, if he presses a button, different data is supposed to be displayed within the same popup.
Now, my problem is that when I press a button a new window is opened by the popup, and I don’t want that, I need the popup just to refresh itself.

The following is the code that I have:

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>
<head>
<script LANGUAGE=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
function submitForm()
{
document.domainSelection.submit();
}
</script>
<title>test popup</title>
</head>

<body>
<form action=&quot;#&quot; method=&quot;post&quot; name=&quot;domainSelection&quot;>
<div align=&quot;center&quot;>
<A style=&quot;text-decoration:none&quot; href=&quot;javascript:submitForm()&quot;>
<font color=&quot;##000000&quot; face=&quot;arial&quot; size=&quot;2&quot;>
<b>link</b>
</font>
</a>
</div>
</form>
</body>
</html>

If any of you know what the problem is, please let me know. I’ll appreciate it!
Thanks,

Dr. Stern


 
Dr Stern,

I'm unable to find any button in your code, so I'm assuming that you want the page to refresh when the user clicks the link...

If so, then changing your HREF from
Code:
javascript:submitForm()
to
Code:
javascript:location.reload(true);
should do the job of reloading the current page.

Hope this helps,

Dan
 
Thank you, but am I going to be able to pass variables as parameters?
Because as you see, I'm submitting a form when I refresh the page....

Dr. Stern
 
You didn't say that previously. You said &quot;I need the popup just to refresh itself.&quot; which I gave you the code for.

I'll have another look and see what I can do for you.

Dan

 
Sorry about not making myself clear. Thank you for your help!

Dr. Stern
 
Dr Stern,

How strange...

I tested your above code verbatim, in both IE 6 and NN 7... and it works as you intended (i.e. the popup window submits back to itself, without opening a new window).

2 questions:

1. What code do you use to open the popup window, and
2. What browser(s) are you experiencing the problems in?

Thanks,
Dan
 
This is the code that I use for opening the window:

domain = showModalDialog(&quot;/test/testPopup.cfm&quot;,window,&quot;help:no;resizable:no;status:no;dialogWidth:533px;dialogHeight:525px&quot;);
if (domain)
{
return true;
}
else
{
return false;
}

Thanks for your help!!
 
Dr. Stern,

I have a working code of a dialogbox refresh. Sample code goes something like this:

function onLoad()
{
window.name=&quot;fixname&quot;;
}

<body onload=&quot;javascript:eek:nLoad();&quot;>


<form method=&quot;POST&quot; name=&quot;MyForm&quot; id=&quot;MyForm&quot; target=&quot;fixName&quot;>


My page has a dropdown box, whenever I change a value in the dropdown, document.MyForm.submit() is called to reload the page. The onLoad triggers assigning a window.name same as the target name in the form post.

However, the dialogbox does not display the page title upon refresh, don't know why? Maybe somebody can figure this out.

/conraba
 
So it's not actually a popup window - it's a modalDialog ;o)

I can't help you on this one any further - sorry ;o(

Dan
 
Oh guys, this is driving me crazy. I tried what Conraba suggested and didn’t work :(

Any other idea?

By the way, this is the code that I tried:

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>

<html>
<head>




<script LANGUAGE=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
function submitForm()
{
document.domainSelection.submit();
}

function onLoad()
{
window.name=&quot;Domain&quot;;
}
</script>
<title>test popup</title>
</head>

<body onload=&quot;javascript:eek:nLoad();&quot;>


<form method=&quot;POST&quot; name=&quot;domainSelection&quot; id=&quot;domainSelection&quot; target=&quot;Domain&quot;>


<A style=&quot;text-decoration:none&quot; href=&quot;javascript:submitForm()&quot;>
<font color=&quot;##000000&quot; face=&quot;arial&quot; size=&quot;2&quot;>
<b>link</b>
</font>
</a>
<br>


</form>

</body>
</html>


Thanks, guys!!!
 
You have to clear your browser cache when testing a page that involves javascript changes. I know it works, I have that code on several pages I am working on.

Try it one more time after clearing out your Temporary Internet Files.

/conraba
 
Dr. Stern,

I see why the code was not working, you were using a link to do a submit of a form, that won't work. In the following code, I used a button instead, this made the modal page to reload:

<!-- --------------Test.htm ---------------- -->
<HTML>
<HEAD>
<META http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-16&quot;>
<TITLE>TEST</TITLE>
<script LANGUAGE=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
function onClick()
{
var domain;
domain = showModalDialog(&quot;test1.asp&quot;,window,&quot;help:no;resizable:no;status:no;dialogWidth:533px;dialogHeight:525px&quot;);
if (domain)
{
return true;
}
else
{
return false;
}
}
</script>

</HEAD>
<BODY>

<P><INPUT id=button1 type=button value=Button name=button1 onclick=&quot;javascript:eek:nClick();&quot;></P>

</BODY>
</HTML>


<!-- ----------------- Test1.asp ---------------- -->
<html>
<head>
<META http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-16&quot;>
<script language=Javascript type=&quot;text/javascript&quot;>
function submitForm()
{
document.domainSelection.submit();
}

function onLoad()
{
alert(window.name);
window.name=&quot;Domain&quot;;
}
</script>
<title>test popup</title>
</head>
<body onload=&quot;javascript:eek:nLoad();&quot;>
<form method=&quot;post&quot; name=&quot;domainSelection&quot; id=&quot;domainSelection&quot; target=&quot;Domain&quot;>
<button id=btnSubmit type=button value=Submit name='btnSubmit&quot;' onclick=&quot;javascript:submitForm();&quot;>Submit</button>
<!--<A style=&quot;text-decoration:none&quot; href=&quot;javascript:submitForm()&quot;>
<font color=&quot;##000000&quot; face=&quot;arial&quot; size=&quot;2&quot;>
<b>link</b>
</font>
</a>-->


</form>
</body>
</html>


Try it, See if this will work for you.

/Conraba
 
Conraba,

Thank you very much, it works like that!

Dr. Stern
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top