PDA

View Full Version : why do I return to top of page from window.showModalDialog


brownbag
03-11-2009, 06:50 PM
I have a simple window.showModalDialog code to bring up a dialog box. It works find until I close the dialog box and the initiating page moves to the top. Any ideas how to stop this: The code is below:

<script language="javascript">
function popUp()
{var url = "ipcc.php"; window.showModalDialog( url, "Intergovernmental Panel on Climate Change", "resizable:yes; scroll:yes; status:no; dialogLeft:100px; dialogTop:100px; dialogHeight:470px; dialogWidth:640px;");}

Thanks.

rangana
03-12-2009, 03:15 AM
How do you call the script? Try to add return false; right after the function call.

Something along this lines:

<a href="#" onclick="popup();return false;">Test</a>


Hope it helps.

brownbag
03-16-2009, 01:09 AM
Thanks. That worked just fine.

Rahul
03-25-2009, 03:31 AM
Hi,
Can I add this 'return false;' statement inside the popup() function?
I did so, but still it is not working...

Rahul

rangana
03-25-2009, 03:38 AM
Please show us the code and a part of the markup that you are using.

RysChwith
03-25-2009, 08:14 AM
You can, but you then have to change to onclick to:<a href="#" onclick="return popup()">Test</a>So that the onclick is still getting an actual return value. Note that the popup function will stop executing as soon as it gets to the "return false" line, so it needs to be the last line in the function.

Rys