:: EXPLINATION ::
在HTML文件中,我正在尝试使用验证码检查加载注册框。表格本身就出现了。验证码没有。所以我知道javascript(在下面发布)得到我想要的东西。但是有一些问题导致我的验证码不能出现。
正如最后一点,我正在瞄准一个id为“splashTarget”的div我用CSS来安排我想要的一切。我不打算发布,因为它可能不相关,但如果你认为我确实需要发布它以获得帮助让我知道。
:: CODE ::
似乎不起作用的表单:
<div class="splash"> </div>
<div style="text-align:left" id="registrationSplash" class="splashContent">
<div style="text-align:right">
<a style="color:darkred" href="javascript:closeSplash()">[ CANCEL ]</a>
</div>
<h1>REGISTER</h1>
<form action="" method="post" id="registerForm">
<?PHP
require_once('recaptchalib.php');
$publickey = "[censored]";
echo recaptcha_get_html($publickey);
echo '<!--'.recaptcha_get_html($publickey).'-->';
?>
<table>
<tr>
<td>First Name:</td>
<td><input type="text" name="firstname" maxlength="60"></td>
<td>Username:</td>
<td><input type="text" name="username" maxlength="30"></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="lastname" maxlength="60"></td>
<td>Password:</td>
<td><input type="password" name="pass" maxlength="30"></td>
</tr>
<tr>
<td>E-mail Address:</td>
<td><input type="text" name="firstname" maxlength="60"></td>
<td>Confirm Password:</td>
<td><input type="password" name="pass2" maxlength="30"></td>
</tr>
<tr>
<th colspan=4 style="text-align:right">
<button onclick="submitFormRegisterSplash()" type="button" name="submit" value="Login">Register!</button>
</th>
</tr>
</table>
</form>
<div id="status" />
</div>
对recaptia的实际调用。
<?PHP
require_once('recaptchalib.php');
$publickey = "[censored]";
echo recaptcha_get_html($publickey);
echo '<!--'.recaptcha_get_html($publickey).'-->';
?>
用于加载注册表单的Javascript函数:
function onRegisterClicked() {
var onRegisterClickedHttp;
if(window.XMLHttpRequest) {
onRegisterClickedHttp = new XMLHttpRequest();
onRegisterClickedHttp.onreadystatechange = function() {
if(onRegisterClickedHttp.readyState==4 && onRegisterClickedHttp.status==200) {
var response = onRegisterClickedHttp.responseText;
document.getElementById("splashTarget").innerHTML = response;
}
}
}
onRegisterClickedHttp.open("GET", "Verification/RegisterSplash.php", true);
onRegisterClickedHttp.send();
}
调用创建后的网页结果
<div id="splashTarget">
<div class="splash"> </div>
<div style="text-align:left" id="registrationSplash" class="splashContent">
<div style="text-align:right">
<a style="color:darkred" href="javascript:closeSplash()">[ CANCEL ]</a>
</div>
<h1>REGISTER</h1>
<form action="" method="post" id="registerForm">
<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV"></script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV" height="300" width="500" frameborder="0"></iframe><br/>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript><!--<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV"></script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=6LehEsgSAAAAAAH2xfKSXKSdldMwoiOqZyO5TupV" height="300" width="500" frameborder="0"></iframe><br/>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript>--> <table>
<tbody><tr>
<td>First Name:</td>
<td><input type="text" name="firstname" maxlength="60"></td>
<td>Username:</td>
<td><input type="text" name="username" maxlength="30"></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="lastname" maxlength="60"></td>
<td>Password:</td>
<td><input type="password" name="pass" maxlength="30"></td>
</tr>
<tr>
<td>E-mail Address:</td>
<td><input type="text" name="firstname" maxlength="60"></td>
<td>Confirm Password:</td>
<td><input type="password" name="pass2" maxlength="30"></td>
</tr>
<tr>
<th colspan="4" style="text-align:right">
<button onclick="submitFormRegisterSplash()" type="button" name="submit" value="Login">Register!</button>
</th>
</tr>
</tbody></table>
</form>
<div id="status">
</div>
</div></div>
该网站的行动是gumonshoe dot net slash Registration 您需要选择尝试注册以查看弹出窗口。我禁用了创建启动屏幕的CSS,认为它可能是z-index的一个问题。情况似乎并非如此。
感谢您的任何提示。
答案 0 :(得分:4)
表格HTML DOES有效(见http://jsfiddle.net/5p5K3/)。该错误是由功能引起的:
使用<script>
注入的 .innerHTML = ...
个标记。未解析<script>
(这些标记内的函数和变量未定义,也未调用)。您必须在页面中包含CAPTCHA代码,而不是使用AJAX添加它。
添加此HTML代码(在<head>
块内):
<script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>
根据我的建议覆盖您的功能(用您的公钥替换<PUBLIC kEY HERE>
):
function onRegisterClicked() {
Recaptcha.create("<PUBLIC KEY HERE>", "splashTarget", {
theme: "red",
callback: Recaptcha.focus_response_field
});
}
答案 1 :(得分:0)
明显问题:插入的重新访问代码已注释掉<!-- -->
。注释掉的html / js不会被渲染/执行。变化
echo '<!--'.recaptcha_get_html($publickey).'-->';
到
echo recaptcha_get_html($publickey);