想做一个类似百度登陆那种效果的弹窗,搜到很多结果,在新建的jsp中使用,可以弹出窗口,但是把这段代码加到项目原有的页面里面就不能弹窗了,项目原本的页面包含很多JS,css,用的是struts标签,希望大家指点下,是哪方面的错误导致新加入的js不发生效果
这是那个例子
script language="javascript">
function show(){
id1.style.height=window.screen.height+"px";
id1.style.width=window.screen.width+"px";
id1.style.display='block';
id2.style.display='block'
}

function hide(){
id1.style.display='none'
id2.style.display='none'
}

</script>
<div id="id2" >
这里可以放内容,或者添加div用innerhtml进行添加内容就可以了
<br/>
<input name="Button1" type="button" value="button" onclick="hide()"/>
<input type="text">
</div>
<div id="id1"> 123</div>
                    <button onclick="show()" class="BUTTON">修改</button>

解决方案 »

  1.   

    id1.style.height=window.screen.height+"px";
    id1.style.width=window.screen.width+"px";
    这样写不需要加‘px’吧
      

  2.   

     document.getElementById("id2").style.height=window.screen.height;
      document.getElementById("id2").style.width=window.screen.width;
    你这么写这两句就对了
      

  3.   

    好吧,其实我本就是个菜鸟,不会JS,才抄啊抄的,
    其实多试几次就好了,至于什么原因错误,我不清楚,我找了个正确的路
    把那些东西作为一个新的js文件导入就没问题了,我就在想,导入一个新的文件和直接把function写在里面难道不一样罢了,慢慢学