whats wrong here

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Geerdink

    whats wrong here

    combo with PHP. what is wrong with the Javascript?

    else
    {
    include("mysql. php");
    $query1 = mysql_query("IN SERT INTO gbook (naam, email, text) VALUES
    ('".$_POST['naam']."', '".$_POST['email']."', '".$_POST['text']."')");
    ?>
    <script language="JavaS cript">
    <!--
    opener.reload(t rue);
    window.close();
    //-->
    </script>
    <?
    }


  • Randy Webb

    #2
    Re: whats wrong here

    Chris Geerdink wrote:[color=blue]
    > combo with PHP. what is wrong with the Javascript?[/color]

    Umm, my first guess is "It doesn't work?". Seriously, whats wrong with
    it depends on what its supposed to be doing, what its doing, and what
    the PHP code is adding to the page. And also, what browser/UA you are
    testing it with.

    [color=blue]
    > else
    > {
    > include("mysql. php");
    > $query1 = mysql_query("IN SERT INTO gbook (naam, email, text) VALUES
    > ('".$_POST['naam']."', '".$_POST['email']."', '".$_POST['text']."')");
    > ?>
    > <script language="JavaS cript">[/color]

    <script type="text/javascript">

    [color=blue]
    > <!--[/color]

    Not needed.
    [color=blue]
    > opener.reload(t rue);[/color]

    window.opener.r eload(true);
    [color=blue]
    > window.close();[/color]

    The window.close() will only work in certain browsers, and only when the
    page was opened via Javascript. Otherwise, you get a confirmation
    telling you that script is trying to close the window.
    [color=blue]
    > //-->[/color]

    Not needed.
    [color=blue]
    > </script>
    > <?
    > }
    >
    >[/color]


    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javas cript FAQ - http://jibbering.com/faq/

    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: whats wrong here

      Randy Webb <hikksnotathome @aol.com> writes:

      I agree with everything else, but there's just one thing I have to
      comment on :)
      [color=blue][color=green]
      >> opener.reload(t rue);[/color]
      >
      > window.opener.r eload(true);[/color]

      That shouln't be necessary. Especially in the global scope, where this
      code is executed, adding one level of indirection to the access of a
      global variable adds nothing except overhead.
      [color=blue][color=green]
      >> window.close();[/color]
      >
      > The window.close() will only work in certain browsers, and only when
      > the page was opened via Javascript. Otherwise, you get a confirmation
      > telling you that script is trying to close the window.[/color]

      But if "opener" is defined, then the page is most likely opened via
      Javascript. If it isn't defined, then the previous line would error.

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      • Randy Webb

        #4
        Re: whats wrong here

        Lasse Reichstein Nielsen wrote:[color=blue]
        > Randy Webb <hikksnotathome @aol.com> writes:
        >
        > I agree with everything else, but there's just one thing I have to
        > comment on :)
        >
        >[color=green][color=darkred]
        >>> opener.reload(t rue);[/color]
        >>
        >>window.opener .reload(true);[/color]
        >
        >
        > That shouln't be necessary. Especially in the global scope, where this
        > code is executed, adding one level of indirection to the access of a
        > global variable adds nothing except overhead.[/color]

        True, it shouldn't be needed, but I have gotten in the habit lately of
        making my references absolute just in case :-\
        [color=blue]
        >[color=green][color=darkred]
        >>> window.close();[/color]
        >>
        >>The window.close() will only work in certain browsers, and only when
        >>the page was opened via Javascript. Otherwise, you get a confirmation
        >>telling you that script is trying to close the window.[/color]
        >
        >
        > But if "opener" is defined, then the page is most likely opened via
        > Javascript. If it isn't defined, then the previous line would error.[/color]

        Yes, if opener is defined...... but opener doesn't have to be defined in
        certain browsers to be able to close a window that script didn't open,
        and it was that exception I was silently alluding to.

        --
        Randy
        Chance Favors The Prepared Mind
        comp.lang.javas cript FAQ - http://jibbering.com/faq/

        Comment

        Working...