开发者

Where is the error IE is finding in this script?

IE continues to give me an error on the next-to-last line stating "Object required". I am not sure where the issue would be. Any advice?

function showdiv()
{
  document.getElementById("dialogue").style.display = "";
  document.getElementById("screen").style.display = "";
  document.getElementById("screen").style.width = getBrowserWidth();
}
function hidediv(opt){
if(opt=="agree"){
  document.Annexation.checkbox.checked = true;
  document.getElementById("dialogue").style.display = "none";
  document.getElementById("dialogue").style.display = "none";
  document.getElementById("screen").style.display = "none";
}else{
  document.getElementById("dialogue").style.display = "none";
  document.getElementById("screen").style.display = "none";
}}

window.onscroll = 开发者_Python百科scrollEvent;
function scrollEvent() {
var y;
if (document.documentElement && !document.documentElement.scrollTop)
  // IE6 +4.01 but no scrolling going on
  y=document.documentElement.scrollTop; 
else if (document.documentElement && document.documentElement.scrollTop){
  // IE6 +4.01 and user has scrolled
  y=document.documentElement.scrollTop;
}
else if (document.body && document.body.scrollTop){
  // IE5 or DTD 3.2
  y=document.body.scrollTop;
}
  document.getElementById("screen").style.top = y+"px";
} 


One of the following probably returns null:

document.getElementById("dialogue")
document.getElementById("screen")
document.Annexation
document.Annexation.checkbox

or getBrowserWidth is not defined.


document.getElementById("screen") Is undefined. Add the following code:

if( !document.getElementById("screen") ) alert( "Spara was right." );

and it will tell you if that is the case or not.


What does Annexation standar for in document.Annexation.checkbox.checked = true;

You have 2 ways to select a checkbox. One is assigning a name value for the tag of checkbox.

<input type="checkbox"  name="ck" />

document.getElementsByName("ck")[0].checked = true; to make the checkbox checked.

Another method is assigning an id for the tag of checkbox.

<input type="checkbox"  id="ck" />

document.getElementById("ck").checked = true; to make the checkbox checked.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜