Opening a new window and not submitting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Todd Cary

    Opening a new window and not submitting

    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_ope nBrWindow('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_ope nBrWindow('lega l.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

  • Peter

    #2
    Re: Opening a new window and not submitting

    Alter the anchor to call a javascript function instead.

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

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

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

    <body onUnload="windo w.opener.checkV alid();">

    Peter.
    "Todd Cary" <todd@aristesof tware.com> wrote in message
    news:wvgRa.2322 $dk4.118452@typ hoon.sonic.net. ..[color=blue]
    > 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_ope nBrWindow('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_ope nBrWindow('lega l.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
    >[/color]


    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: Opening a new window and not submitting

      "Peter" <ap.lamb@ntlwor ld.com> writes:
      [color=blue]
      > Alter the anchor to call a javascript function instead.
      >
      > <a href="javascrip t:validate();"> Link Text</a>[/color]

      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 - lrn@hotpop.com
      Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      Working...