Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script works in firefox but null error in ie

Status
Not open for further replies.

justride

Programmer
Joined
Jan 9, 2004
Messages
251
Location
US
Hi all,

I have a script that countdowns and then I call a new page in a new browser, however the line that calls the submit() function to load a new page produces a null object error in ie but works in firefox.

heres the code:
the window.document.frmBestSubmit.submit.click(); line fails in ie but not firefox, and it works nice in firefix and the form is submitted automatically.
Code:
script language="JavaScript">
						
	//configure refresh interval (in seconds)
						var countDownInterval=10;
						//configure width of displayed text, in px (applicable only in NS4)
						var c_reloadwidth=200
						
						</script>
						
						
						<ilayer id="c_reload" width=&{c_reloadwidth}; ><layer id="c_reload2" width=&{c_reloadwidth}; left=0 top=0></layer></ilayer>
						
						<script>
						
						var countDownTime=countDownInterval+1;
						function countDown(){
						countDownTime--;
						if (countDownTime <=0){
						countDownTime=countDownInterval;
						clearTimeout(counter)
						window.document.frmBestSubmit.submit.click();
						window.location.reload("[URL unfurl="true"]http://www.ctremblay.com/TrillionCuts/TrillionCutsVoteAutomation.php?start=true")[/URL]
						return
						}
						if (document.all) //if IE 4+
						document.all.countDownText.innerText = countDownTime+" ";
						else if (document.getElementById) //else if NS6+
						document.getElementById("countDownText").innerHTML=countDownTime+" "
						else if (document.layers){ //CHANGE TEXT BELOW TO YOUR OWN
						document.c_reload.document.c_reload2.document.write('<span class="style1"><center>next submit in <b id="countDownText">'+countDownTime+' </b> seconds</center></span>')
						document.c_reload.document.c_reload2.document.close()
						}
						counter=setTimeout("countDown()", 1000);
						}
						
						function startit(){
						if (document.all||document.getElementById) //CHANGE TEXT BELOW TO YOUR OWN
						document.write('<span class="style1"><center>next submit in <b id="countDownText">'+countDownTime+' </b> seconds</center></span>')
						countDown()
						}
						
						if (document.all||document.getElementById)
						startit()
						else
						window.onload=startit
						
						</script>
Thanks for any tips
Chris
 
1) never name an element with a javascript keyword (submit)
2) call it like this:
Code:
document.forms['frmBestSubmit'].submit();
3) avoid using the 'all' collection whenever you can. and you always can.

*cLFlaVA
----------------------------
[tt]your mom goes to college[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
hmm no error, but the form when submitted, is supposed to load in a new window and i dont see any new windows load, but there arent any errors. any ideas?

thanks so much!
 
Code:
<form name="frmBestSubmit" method="post" target="_blank" action="[URL unfurl="true"]http://providencephoenix.com/thebest/process2.asp">[/URL]
works like a charm in firefox, a new window opens but in ie, the pae refreshes but no errors and no new window with the url in the form action field.
 
<html>
<head>



<style type="text/css">
<!--
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
color: #454545;
}
.style2 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
</head>


<body>

<script LANGUAGE="JavaScript">
document.frmBestSubmit.submit();
var strPageOrSection = "best";
_version=10;
</script>

<style type="text/css">
<!--
.style7 {font-family: Arial, Helvetica, sans-serif}
.style8 {font-size: 11px}
.style10 {color: #454545}
-->
</style>
<form name="frmBestSubmit" method="post" target="_blank" action="<input type="hidden" id="txtRegion" name="txtRegion" value="3">

<table width="100%" align="center" cellpadding="0" cellspacing="2" border="0">
<tr>
<td class="body" align="center">
<table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="body" align="left" style="padding-top:10px; font-family: Arial, Helvetica, sans-serif; font-size: 11px; color: #454545;"><h2 class="style10"><br>
</h2>
</td>
</tr>
</table> </td>
</tr>
<tr>
<td align="center" class="small style7 style8 style10">
<table width="50%" align="center" border="0">
<tr>
<td colspan="2">

</td>
</tr>
<tr>
<td colspan="2"><center><img src="1.jpg" width="434" height="280"></center>
</td>
</tr>
<tr>
<td colspan="2"><input type="hidden" size="30" id="txtName2" name="txtName" class="small">
</td>
</tr>
<tr>
<td colspan="2">
<input type="hidden" size="30" id="txtEmail" name="txtEmail" class="small">
</td>
</tr>
<tr>
<td colspan="2">
<input type="hidden" size="20" id="txtPhone" name="txtPhone" class="small">
</td>
</tr>
<tr>
<td colspan="2">
<input type="hidden" size="20" id="txtAge" name="txtAge" class="small">
</td>
</tr>
<tr>
<td width="35%" height="24" align="right"><span class="style8 style1">Your #1 DJ IS: </span></td>
<td width="65%"><input name='125' type='text' class='style1' id='125' value="Trillion Cuts" size='30' maxlength='100'></td>
</tr>
<tr>
<td width="35%" height="24">&nbsp;</td>
<td width="65%"> <input name="submit" type="submit" class="style1" id="submit2" value="Submit my vote manually!"></td>
</tr>
<tr>
<td height="24" colspan="2"><span class="style8"><center><img src="2.jpg" width="457" height="113"></center></span> </td>
</tr>
</table>
<br></td>
</tr>
<tr>
<td class="body style7 style8 style10">

</td>
</tr>
</table>
</form>
<?php
if ($start=="true"){
echo "
<script language=\"JavaScript\">



//configure refresh interval (in seconds)
var countDownInterval=10;
//configure width of displayed text, in px (applicable only in NS4)
var c_reloadwidth=200

</script>


<ilayer id=\"c_reload\" width=&{c_reloadwidth}; ><layer id=\"c_reload2\" width=&{c_reloadwidth}; left=0 top=0></layer></ilayer>

<script>

var countDownTime=countDownInterval+1;
function countDown(){
countDownTime--;
if (countDownTime <=0){
countDownTime=countDownInterval;
clearTimeout(counter)
document.forms['frmBestSubmit'].submit();
window.location.reload(\" return
}
if (document.all) //if IE 4+
document.all.countDownText.innerText = countDownTime+\" \";
else if (document.getElementById) //else if NS6+
document.getElementById(\"countDownText\").innerHTML=countDownTime+\" \"
else if (document.layers){ //CHANGE TEXT BELOW TO YOUR OWN
document.c_reload.document.c_reload2.document.write('<span class=\"style1\"><center>next submit in <b id=\"countDownText\">'+countDownTime+' </b> seconds</center></span>')
document.c_reload.document.c_reload2.document.close()
}
counter=setTimeout(\"countDown()\", 1000);
}

function startit(){
if (document.all||document.getElementById) //CHANGE TEXT BELOW TO YOUR OWN
document.write('<span class=\"style1\"><center>next submit in <b id=\"countDownText\">'+countDownTime+' </b> seconds</center></span>')
countDown()
}

if (document.all||document.getElementById)
startit()
else
window.onload=startit

</script>";

}



</body>
</html>
 
its a script to keep submitting a form. its messy buy works in firefox but not ie, any idea why?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top