468,170 Members | 1,923 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,170 developers. It's quick & easy.

whats wrong here

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>
<?
}
Jul 23 '05 #1
3 2159
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/
Jul 23 '05 #2
Randy Webb <hi************@aol.com> 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 - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #3
Lasse Reichstein Nielsen wrote:
Randy Webb <hi************@aol.com> 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/
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by iz0nlee | last post: by
1 post views Thread by Matthew Wilson | last post: by
5 posts views Thread by kernel.lover | last post: by
3 posts views Thread by mahsa | last post: by
4 posts views Thread by blah | last post: by
5 posts views Thread by islayer | last post: by
reply views Thread by gcreed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.