By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,379 Members | 1,791 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,379 IT Pros & Developers. It's quick & easy.

Opening a new window and not submitting

P: n/a
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

Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.
"Todd Cary" <to**@aristesoftware.com> wrote in message
news:wv*******************@typhoon.sonic.net...
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

Jul 20 '05 #2

P: n/a
"Peter" <ap*****@ntlworld.com> writes:
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.