whats wrong here

Discussion in 'Javascript' started by Chris Geerdink, Jun 28, 2004.

  1. combo with PHP. what is wrong with the Javascript?

    else
    {
    include("mysql.php");
    $query1 = mysql_query("INSERT INTO gbook (naam, email, text) VALUES
    ('".$_POST['naam']."', '".$_POST['email']."', '".$_POST['text']."')");
    ?>
    <script language="JavaScript">
    <!--
    opener.reload(true);
    window.close();
    //-->
    </script>
    <?
    }
    Chris Geerdink, Jun 28, 2004
    #1
    1. Advertising

  2. Chris Geerdink

    Randy Webb Guest

    Chris Geerdink wrote:
    > combo with PHP. what is wrong with the Javascript?


    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.


    > else
    > {
    > include("mysql.php");
    > $query1 = mysql_query("INSERT INTO gbook (naam, email, text) VALUES
    > ('".$_POST['naam']."', '".$_POST['email']."', '".$_POST['text']."')");
    > ?>
    > <script language="JavaScript">


    <script type="text/javascript">


    > <!--


    Not needed.

    > opener.reload(true);


    window.opener.reload(true);

    > window.close();


    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.

    > //-->


    Not needed.

    > </script>
    > <?
    > }
    >
    >



    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq/
    Randy Webb, Jun 28, 2004
    #2
    1. Advertising

  3. Randy Webb <> writes:

    I agree with everything else, but there's just one thing I have to
    comment on :)

    >> opener.reload(true);

    >
    > window.opener.reload(true);


    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.

    >> window.close();

    >
    > 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.


    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 -
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    'Faith without judgement merely degrades the spirit divine.'
    Lasse Reichstein Nielsen, Jun 28, 2004
    #3
  4. Chris Geerdink

    Randy Webb Guest

    Lasse Reichstein Nielsen wrote:
    > Randy Webb <> writes:
    >
    > I agree with everything else, but there's just one thing I have to
    > comment on :)
    >
    >
    >>> opener.reload(true);

    >>
    >>window.opener.reload(true);

    >
    >
    > 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.


    True, it shouldn't be needed, but I have gotten in the habit lately of
    making my references absolute just in case :-\

    >
    >>> window.close();

    >>
    >>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.

    >
    >
    > 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.


    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.javascript FAQ - http://jibbering.com/faq/
    Randy Webb, Jun 28, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthew

    Whats wrong here...

    Matthew, Dec 2, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    369
    Matthew
    Dec 2, 2005
  2. kernel.lover

    whats the significance of void * here

    kernel.lover, Mar 9, 2005, in forum: C Programming
    Replies:
    5
    Views:
    408
    Lawrence Kirby
    Mar 10, 2005
  3. iz0nlee

    whats wrong here?

    iz0nlee, Jul 12, 2003, in forum: Javascript
    Replies:
    9
    Views:
    170
    Evertjan.
    Jul 13, 2003
  4. please-answer-here

    nearlynewbie - whats wrong here

    please-answer-here, Jun 18, 2005, in forum: Javascript
    Replies:
    20
    Views:
    244
    please-answer-here
    Jun 19, 2005
  5. Randell_D
    Replies:
    14
    Views:
    189
    Randell_D
    Dec 25, 2007
Loading...

Share This Page