各位业内前辈。在此先向你们致敬。你们辛苦了
我现在需要做一个浮动广告。就像www.sina.com右下角那个层一样的效果。
但是有要求,各游览器兼容。跨语言。
全部代码都用javascript写,层也要是javascript生成的。
我想在层上加几个超链
我自己想是用javascript最合适了,但现在我自己做的一个,他不能随滚动条滚动。
给个例子让我参考。
谢谢
我现在需要做一个浮动广告。就像www.sina.com右下角那个层一样的效果。
但是有要求,各游览器兼容。跨语言。
全部代码都用javascript写,层也要是javascript生成的。
我想在层上加几个超链
我自己想是用javascript最合适了,但现在我自己做的一个,他不能随滚动条滚动。
给个例子让我参考。
谢谢
解决方案 »
- Extjs4做的树,单击或选中时有的能加载有的不行
- 如何获取已知节点的同级节点?
- 这是什么加密的?如何解密?
- 如何用CSS实现鼠标经过表格的某一行,该行的背景颜色发生改变,移出之后恢复?(不用onmouse事件,用CSS)
- 请问在 HTC 中如何定义window.onresize() 事件?
- javascript 如何进行数字运算,并保留指定位数的小数?
- 请教一个问题!!!!
- 一个很有挑战性的问题,关于IE的关闭按钮!
- 如何用js判断输入框提交的内容第一个和最后一个不能为".",中间的内容为英文字母和.?
- 如何让我所在页上的鼠标刷新时产生的漏斗消失(用java特效中的把鼠标变小花的原理)
- 帮忙弄个刷新的问题
- 静态网页中如何对cookie进行读写?
var width = document.body.clientWidth;
var height = document.body.clientHeight; var divWidth = 200;
var divHeight = 100;
var div = document.createElement("div");
div.setAttribute("id", "ShowDiv");
div.style.zIndex = 99;
div.style.width = divWidth + "px";
div.style.height = divHeight+"px";
div.style.position = "absolute";
div.style.backgroundColor = "Red";
div.innerHTML = "HELLO";
div.style.top = (height - divHeight) + "px";
div.style.left = (width - divWidth) + "px";
document.body.appendChild(div); window.onresize = function() {
width = document.body.clientWidth;
height = document.body.clientHeight;
var showDiv = document.getElementById("ShowDiv");
showDiv.style.top = height - divHeight + "px";
showDiv.style.left = width - divWidth + "px";
}
window.onscroll = function() {
width = document.body.clientWidth;
height = document.body.clientHeight;
var showDiv = document.getElementById("ShowDiv");
showDiv.style.top = height - divHeight + document.body.scrollTop + "px";
showDiv.style.left = width - divWidth + "px";
}
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<script type="text/javascript"> var container;
var width, height;
window.onload = setPosition;
window.onscroll = setPosition;
window.onresize = setPosition; function setPosition()
{
container = document.getElementById("container");
width = document.documentElement.clientWidth;
height = document.documentElement.clientHeight;
container.style.top = (height - container.offsetHeight) + (document.documentElement.scrollTop) + "px";
container.style.right = "0px";
}
</script>
</head>
<body><div style="height:1200px;">dddddddd</div><div style="position:absolute;width:300px;border:1px solid #ccc;" id="container">
<div style="padding:4px;background-color:#ffffcc;border-bottom:1px solid #ccc;font-size:12px">内容标题</div>
<div style="padding:4px;font-size:12px;line-height:1.5;">
普通的掩码越靠近顶端优先权就越高,但是这个规则存在例外。如果 rarfiles.lst 包含两个掩码,并且所有文件既匹配第一个掩码,也匹配第二个掩码, 较小的子集或者更精确的匹配拥有更高的优先权。例如,如果你用 *.cpp 和 f*.cpp 掩码,f*.cpp 拥有更高的优先权。
</div>
</div></body>
</html>
在body区域写的层就不能达到跨语言的效果了
全javascript的
truelove12大哥的
这个已经能达到要求了。只要肯给答案,我就肯给分学习的,给完各位有答案大哥的分后。剩下的就是你们。
不过我想要给我最满意的80分
<head>
<title> Scroll Box </title>
<script type="text/javascript">
var $ = function(id){return document.getElementById(id)}
var box_init = function(){
var box = document.createElement('div');
box.setAttribute('id','box');
box.style.cssText = "position:absolute;width:300px;height:200px;border:1px solid #ccc;";
var title = document.createElement('div');
title.setAttribute('id','title');
title.innerHTML = '新闻标题';
title.style.cssText = "padding:4px;background-color:#ffffcc;border-bottom:1px solid #ccc;font-size:12px";
var content = document.createElement('div');
content.setAttribute('id','content');
content.style.cssText = "padding:4px;font-size:12px;line-height:1.5;"
content.innerHTML = '微软征服中国的过程,也是他从一家非常美国的公司变成一家非常中国公司的过程。他在美国时,与政府保持距离,在市场上奉行高价策略,同时严厉打击盗版。而在中国,他与政府关系亲密,在市场上甚至卖出了199元的OFFICE,同时对盗版屈服是他的长期策略。这就叫做适应水土。';
box.appendChild(title)
box.appendChild(content)
document.body.appendChild(box) $('box').style.left = document.body.clientWidth - parseInt($('box').offsetWidth)
$('box').style.top = document.body.clientHeight
}var box_scroll = function(){
var delta = Math.ceil( parseInt($('box').style.top) - (document.body.scrollTop + document.body.clientHeight - parseInt($('box').offsetHeight)) )
if(Math.abs(delta) > 0){
$('box').style.top = (parseInt($('box').style.top) - delta*0.1)+'px'
}
}
</script>
</head><body>
<script type="text/javascript">
for(var i = 0;i<100;i++){document.write('CSDN News!<br>')}box_init();
setInterval('box_scroll()',10)
</script>
</body>
</html>
http://www.lxasp.com/jquery/demo/floatfixbox/right-bottom-tip-demo3.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- 上面2行标准很重要,如果你要兼容更多标准,找资料完善窗口的高度判断吧。 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
;(function(){
window.onload = function(){
var div = document.createElement("div");
div.style.width = "300px"; //设置宽度
div.style.position = "absolute";
div.innerHTML = "<div style='border:#000000 1px solid;'>这里是你要填写的内容</div>"; //设置内容
document.body.appendChild(div);
function setPosition()
{
width = document.documentElement.clientWidth || document.body.clientWidth;
height = document.documentElement.clientHeight || document.body.clientHeight;
div.style.top = (height - div.offsetHeight) + (getScrollTop()) + "px";
div.style.right = "0px";
} function getScrollTop(){
return document.documentElement.scrollTop || document.body.scrollTop;
}
setPosition();
window.onscroll = setPosition;
window.onresize = setPosition;
};
})();
</script>
</head><body>
</body>
</html>