|
-
February 16th, 2008, 07:36 PM
#4
Re: Javascript submits form twice
Hi,
I've now found the solution, which is in this bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=236858, so I thought I'd share what I did with everyone.
According to the bug report, the absence of a "content-type text/html; charset=iso-8859-1" header or <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> meta tag in the page causes the browser to use it's default charset, which it may decide is wrong once it gets to process the actual data on the page. This is what causes the browser to re-request the page to be able to process it using the correct charset, hence submitting the form twice. Not the most desirable result, I grant you, but that how it's been designed to work, currently.
So, I tried the suggested fix and found that putting both or just the meta tag did solve the problem, but not consistently enough, because it still happened every so often.
So, I put in a bit of code to not use the javascript when the browser is Firefox, as that is the only browser in which the problem occurs.
Code:
<?php
if (USER_BROWSER_AGENT <> "FIREFOX"):
?>
<script language="JavaScript1.2" type="text/javascript"><!--
<?php
require(JS_STOP_THIEF);
?>
--></script>
<?php
endif;
?>
USER_BROWSER_AGENT is determined by this code, which I thought might be useful for anyone who doesn't already have something similar:
Code:
if (!empty($_SERVER["HTTP_USER_AGENT"])):
define("USER_AGENT", $_SERVER["HTTP_USER_AGENT"]);
elseif (!empty($HTTP_SERVER_VARS["HTTP_USER_AGENT"])):
define("USER_AGENT", $HTTP_SERVER_VARS["HTTP_USER_AGENT"]);
else:
define("USER_AGENT", "");
endif;
if (strstr(USER_AGENT, "Win")):
define("USER_OS", "Win");
elseif (strstr(USER_AGENT, "Mac")):
define("USER_OS", "Mac");
elseif (strstr(USER_AGENT, "Linux")):
define("USER_OS", "Linux");
elseif (strstr(USER_AGENT, "Unix")):
define("USER_OS", "Unix");
elseif (strstr(USER_AGENT, "OS/2")):
define("USER_OS", "OS/2");
else:
define("USER_OS", "Other");
endif;
if (ereg("Opera(/| )([0-9].[0-9]{1,2})", USER_AGENT, $aMatches)):
define("USER_BROWSER_VER", $aMatches[2]);
define("USER_BROWSER_AGENT", "OPERA");
elseif (ereg("MSIE ([0-9].[0-9]{1,2})", USER_AGENT, $aMatches)):
define("USER_BROWSER_VER", $aMatches[1]);
define("USER_BROWSER_AGENT", "IE");
elseif (ereg("OmniWeb/([0-9].[0-9]{1,2})", USER_AGENT, $aMatches)):
define("USER_BROWSER_VER", $aMatches[1]);
define("USER_BROWSER_AGENT", "OMNIWEB");
elseif (ereg("(Konqueror/)(.*)(;)", USER_AGENT, $aMatches)):
define("USER_BROWSER_VER", $aMatches[2]);
define("USER_BROWSER_AGENT", "KONQUEROR");
elseif (ereg("Mozilla/([0-9].[0-9]{1,2})", USER_AGENT, $aMatches)
&& ereg("Firefox/([0-9]*)", USER_AGENT, $aMatches2)
):
define("USER_BROWSER_VER", $aMatches[1] . "." . $aMatches2[1]);
define("USER_BROWSER_AGENT", "FIREFOX");
elseif (ereg("Mozilla/([0-9].[0-9]{1,2})", USER_AGENT, $aMatches)
&& ereg("Safari/([0-9]*)", USER_AGENT, $aMatches2)
):
define("USER_BROWSER_VER", $aMatches[1] . "." . $aMatches2[1]);
define("USER_BROWSER_AGENT", "SAFARI");
elseif (ereg("Mozilla/([0-9].[0-9]{1,2})", USER_AGENT, $aMatches)):
define("USER_BROWSER_VER", $aMatches[1]);
define("USER_BROWSER_AGENT", "MOZILLA");
else:
define("USER_BROWSER_VER", 0);
define("USER_BROWSER_AGENT", "OTHER");
endif;
Hope that helps.
Debbie
QuicknEasySalesPro.com
- your quick and easy, yet powerful solution for managing your
membership site sales, downloads and affiliates.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|