我有我的网站不能正常工作的代码,我一直无法弄清楚为什么...JavaScript表单提交失败
下面是代码:
if (self.location.href == top.location.href) {
document.fastform.submit();
document.getElementById(fastform).submit();
}
现在如果我把表单以外的其他东西提交到if语句中,它可以正常工作。这只是当我做表单提交它永远不会奏效代码...
这里是表单代码:
<form id="fastform" name="fastform" ACTION="/amember.php">
<INPUT TYPE="text" NAME="myurl" ID="myurl">
<input type="submit" />
</form>
感谢您的帮助家伙!
到目前为止,没有任何建议的工作,我尝试了几种不同的变化,像在getelementbyid周围的fastform引号。这是我的整个javascript程序:
<script type="text/javascript">
function geturl() {
var locate = document.location
document.fastform.myurl.value = locate
}
window.onload = geturl;
if (self.location.href == top.location.href) {
var f=document.forms.fastform; f.submit();
}
</script>
感谢您的建议!
好的,所以在这里使用一些建议的代码我得到了它的工作。问题在于if语句没有在正确的时间执行,我移动了所有东西,这样if语句最后被执行,并且所有的东西都开始工作了。下面是完整的(功能)代码:
<script type="text/javascript">
function geturl() {
var locate = document.location
document.fastform.myurl.value = locate
getmeoutofhere()
}
window.onload = geturl;
function getmeoutofhere() {
if (self.location.href == top.location.href) {
document.getElementById('fastform').submit();
}
}
</script>
<form id="fastform" name="fastform" ACTION="/amember.php" style="visibility:hidden;">
<INPUT TYPE="text" NAME="myurl" ID="myurl" />
<input type="submit" />
</form>
此建议没有工作...添加到我的原始文章整个程序。 –
写在上面我们的代码,如果块,我已经检查它的正常工作 –
我使用这个代码: