Opening a new window and not submitting

T

Todd Cary

I want to have a link on a php page that when opened, has to be closed
in order to move on. I have done this on pages using a button and
JavaScript as follows:

<input name="btnHelp" type="button" value="Help"
onClick="MM_openBrWindow('help.html','', 'toolbar=no, status=yes,
scrollbars=no, resizable=no, width=790, height=600')";">

When the button is clicked, the form is *NOT* submitted - this is what I
want.

However, if I use an anchor, the form is submitted. Is there a way to
prevent this? Here is the code I tried:

<a href="#" onClick="MM_openBrWindow('legal.php', '', 'toolbar=no,
status=yes, scrollbars=no, resizable=no, width=790, height=600')";">

When the above is executed, the page is submitted, and I do not want
that....

Todd
 
P

Peter

Alter the anchor to call a javascript function instead.

<a href="javascript:validate();">Link Text</a>

<script type="text/javascript">
function validate() {
var popup = window.open(.....);
if (someCondition) {
document.formname.submit();
}
}
</script>

If you are using pop up windows, you may need to call a function in the
opener such as

<body onUnload="window.opener.checkValid();">

Peter.
 
L

Lasse Reichstein Nielsen

Peter said:
Alter the anchor to call a javascript function instead.

<a href="javascript:validate();">Link Text</a>

You shouldn't use the javascript: pseudo-protocol. Using the
onclick event of the link is much better, and also allows you to have
a link as fallback for people without javascript.

<URL:http://jibbering.com/faq/#FAQ4_24>

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top