var clickUrl = "http://www.baidu.com"; var Then = new Date(); Then.setTime(Then.getTime() + 0 ); //秒分 var cookieString = new String(document.cookie); var cookieHeader = "POPWIN" ; var beginPosition = cookieString.indexOf(cookieHeader); if (beginPosition == -1) { var newtop=0 var newleft=0 if (navigator.appName == "Netscape") { layerStyleRef="layer."; layerRef="document.layers"; styleSwitch=""; } else { layerStyleRef="layer.style."; layerRef="document.all"; styleSwitch=".style"; }
} var autoclick_ok=false; if (navigator.appName == "Netscape") { // firefox处理 sAlert(); } else {
sAlert(); } /****************************************************/ //函数 /*****************************************************/ //创建div 对象 function sAlert() {
Alpha滤镜需要背景色如何设置,能给个代码吗?
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<center>
<script type="text/javascript">
function sAlert()
{ var div = document.createElement("div");
div.style.top = 300;
div.style.left = 300;
//div.style.backgroundColor = "red";
div.style.display = "inline";
div.innerHTML = "hello, world.";
div.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75)";
div.style.opacity="0.6";
document.body.appendChild(div); div.onclick=function() {
divclick();
}
}
function divclick(){
alert("123")
}
</script>
</table>
</center>
</body>
<script type="text/javascript">
sAlert()</script>
</html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<center>
<script type="text/javascript">
function sAlert()
{ // var div = document.createElement("div");
// div.style.top = 300;
// div.style.left = 300;
// //div.style.backgroundColor = "red";
// div.style.display = "inline";
// div.innerHTML = "hello, world.";
// div.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75)";
// div.style.opacity="0.6";
var bgObj=document.createElement("div");
bgObj.setAttribute( 'id ', 'bgDiv ');
bgObj.style.position="absolute";
bgObj.style.top="0";
bgObj.innerHTML = "00000000000000";
// bgObj.style.background="#777"; //?置div背景色
//bgObj.BACKGROUND-COLOR="transparent";
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75)";
bgObj.style.opacity="0.6";
bgObj.style.left="0";
bgObj.style.width=document.body.offsetWidth + "px";
bgObj.style.height=document.body.scrollHeight + "px";
bgObj.onclick=function() {
divclick();
}
document.body.appendChild(bgObj);
}
function divclick(){
alert("123")
}
</script>
</table>
</center>
</body>
<script type="text/javascript">
sAlert()</script>
</html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<center>
<script type="text/javascript">
function sAlert()
{ // var div = document.createElement("div");
// div.style.top = 300;
// div.style.left = 300;
// //div.style.backgroundColor = "red";
// div.style.display = "inline";
// div.innerHTML = "hello, world.";
// div.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75)";
// div.style.opacity="0.6";
var bgObj=document.createElement("div");
bgObj.setAttribute( 'id ', 'bgDiv ');
bgObj.style.position="absolute";
bgObj.style.top="0";
bgObj.innerHTML = "00000000000000";
// bgObj.style.background="#777"; //?置div背景色
//bgObj.BACKGROUND-COLOR="transparent";
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75)";
bgObj.style.opacity="0.6";
bgObj.style.left="0";
bgObj.style.width=document.body.offsetWidth + "px";
bgObj.style.height=document.body.scrollHeight + "px";
bgObj.onclick=function() {
divclick();
}
document.body.appendChild(bgObj);
}
function divclick(){
alert("123")
}
</script>
</table>
</center>
</body>
<script type="text/javascript">
sAlert()</script>
</html>
如果加这个就不对了
bgObj.innerHTML = "00000000000000"; 加个这个
我的需求是在层上不能有任何内容的。
var clickUrl = "http://www.baidu.com";
var Then = new Date();
Then.setTime(Then.getTime() + 0 ); //秒分
var cookieString = new String(document.cookie);
var cookieHeader = "POPWIN" ;
var beginPosition = cookieString.indexOf(cookieHeader);
if (beginPosition == -1)
{
var newtop=0
var newleft=0
if (navigator.appName == "Netscape")
{
layerStyleRef="layer.";
layerRef="document.layers";
styleSwitch="";
}
else
{
layerStyleRef="layer.style.";
layerRef="document.all";
styleSwitch=".style";
}
} var autoclick_ok=false; if (navigator.appName == "Netscape")
{
// firefox处理
sAlert();
}
else
{
sAlert();
} /****************************************************/
//函数
/*****************************************************/
//创建div 对象
function sAlert()
{
// bgObj.setAttribute("onclick",function(){alert('dd')});
var sWidth,sHeight;
sWidth=document.body.offsetWidth;
sHeight=document.body.offsetHeight;
var bgObj=document.createElement("div");
bgObj.setAttribute('id','bgDiv');
bgObj.style.position="absolute";
bgObj.style.top="0";
//bgObj.style.background="#777";
bgObj.innerHTML = "00000000000000";
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75)";
bgObj.style.opacity="0.6";
bgObj.style.left="0";
bgObj.style.width=sWidth + "px";
bgObj.style.height=sHeight + "px";
bgObj.onclick=function() {
divclick();
}
document.body.appendChild(bgObj);
}
//div点击事件
function divclick()
{
alert('dd');
//var divbg = document.getElementById("bgDiv");
//document.body.removeChild(divbg);//移除div对象
//window.open('http://www.baidu.com','_blank');//链接
//toExit(); //清除cookie
}
//清除cookie
function toExit()
{
autoclick_ok=true;
document.cookie = "Cookie9=POPWIN;expires="+ Then.toGMTString() +";path=/";//清除cookie
}
</SCRIPT>
但是我如果不对这个层加
bgObj.style.background="#777"; 或
bgObj.innerHTML = "00000000000000";
属性的话 div的事件是无法触发,我一直查不出原因。
高人救命啊!
加上 bgObj.style.background = "url(trans.gif) repeat";//背景透明就可以了。
不过我还是觉的奇怪,时间跟这个背景属性有什么关系啊。昨天晚上我确定我搞了一个不需要设置背景色也能触发。
都是早上卡巴把我代码给删了。
谢谢各位,接分吧