asp语言编写的图片漂浮代码是什么

gxwy89feixue 2011-05-08 05:48:03
如果有代码的请发给我一个,谢谢
...全文
232 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lwdww 2011-05-19
  • 打赏
  • 举报
回复
怎么不结账啊
gxwy89feixue 2011-05-19
  • 打赏
  • 举报
回复
我的天哪,这么多谢谢了
孟子E章 2011-05-10
  • 打赏
  • 举报
回复
完整的代码
<!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">
<head>
<script type="text/javascript">
//函数
var FloatContent = window.FloatContent || function () {
if (!window.Instances) {
window.Instances = {};
window.Instances.Get = function (i) {
return window.Instances[i];
}
}
var Instance = this;
this.Timer1 = null;
this.Speed = 10;
this.HtmlContent = "";
this.DivFloat = null;
this.Guid = ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".replace(/[x]/g, function (c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : r & 0x3 | 0x8; return v.toString(16); }).toUpperCase());
//全局实例集合。
window.Instances[this.Guid] = this;

this.Start = function () {
var d = document.createElement("div");
d.style.position = "absolute";
d.style.backgroundColor = "red";
d.innerHTML = this.HtmlContent;
d.setAttribute("id", this.Guid);
if (d.addEventListener) {
d.addEventListener("mouseover", function () { Instance.Stop(); }, false);
d.addEventListener("mouseout", function () { Instance.ReStart(); }, false);
}
else {
d.attachEvent("onmouseover", function () { Instance.Stop(); });
d.attachEvent("onmouseout", function () { Instance.ReStart(); });
}
document.body.appendChild(d);
this.DivFloat = d;
Instance.ReStart();
}

this.ReStart = function () {
this.Timer1 = window.setInterval("window.Instances['" + this.Guid + "'].changePosition()", this.Speed);
}

this.Stop = function () { if (this.Timer1) window.clearInterval(this.Timer1); }

this.x = Math.ceil(Math.random() * 600), this.y = Math.ceil(Math.random() * 400);
this.xStep = 2, this.yStep = 2;
this.Direction = true; this.yDirection = true;

function getViewportWidth() {
var width = 0;
if (document.documentElement && document.documentElement.clientWidth) {
width = document.documentElement.clientWidth;
}
else if (document.body && document.body.clientWidth) {
width = document.body.clientWidth;
}
else if (window.innerWidth) {
width = window.innerWidth;
}
return width;
}

function getContentHeight() {
if (document.body && document.body.offsetHeight) {
return document.body.offsetHeight;
}
}

function getViewportHeight() {
var height = 0;
if (window.innerHeight) {
height = window.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight) {
height = document.documentElement.clientHeight;
}
else if (document.body && document.body.clientHeight) {
height = document.body.clientHeight;
}
else if (window.innerHeight) {
height = window.innerHeight;
}
return height;
}

function getViewportScrollX() {
var scrollX = 0;
if (document.documentElement && document.documentElement.scrollLeft) {
scrollX = document.documentElement.scrollLeft;
}
else if (document.body && document.body.scrollLeft) {
scrollX = document.body.scrollLeft;
}
else if (window.pageXOffset) {
scrollX = window.pageXOffset;
}
else if (window.scrollX) {
scrollX = window.scrollX;
}
return scrollX;
}

function getViewportScrollY() {
var scrollY = 0;
if (document.documentElement && document.documentElement.scrollTop) {
scrollY = document.documentElement.scrollTop;
}
else if (document.body && document.body.scrollTop) {
scrollY = document.body.scrollTop;
}
else if (window.pageYOffset) {
scrollY = window.pageYOffset;
}
else if (window.scrollY) {
scrollY = window.scrollY;
}
return scrollY;
}

function getViewportScrollHeight() {
var scrollH = 0;
if (document.documentElement && document.documentElement.scrollHeight) {
scrollH = document.documentElement.scrollHeight;
}
else {
scrollH = document.body.scrollHeight;
}
return scrollH;
}

this.changePosition = function () {
this.x = this.x + this.xStep * (this.xDirection ? 1 : -1);
this.y = this.y + this.yStep * (this.yDirection ? 1 : -1);

//若超出浏览器的宽度反向移动
if (this.x <= 0) this.xDirection = true;
if (this.x >= getViewportWidth() - this.DivFloat.offsetWidth) this.xDirection = false;

if (this.y <= 0) this.yDirection = true;
if (this.y >= getViewportHeight() - this.DivFloat.offsetHeight) this.yDirection = false;

//Div重新定位
this.DivFloat.style.top = this.y + getViewportScrollY() + "px";
this.DivFloat.style.left = this.x + getViewportScrollX() + "px";
}
}


</script>
</head>
<body>
<script language="javascript" type="text/javascript">
dd = new FloatContent();
dd.Speed = 50;
dd.HtmlContent = "<a href='http://dotnet.aspx.cc/'><img src='http://dotnet.aspx.cc/Images/logoSite.gif' border='0' /></a>";
dd.Start();

d2 = new FloatContent();
d2.Speed = 10;
d2.HtmlContent = "<a href='http://dotnet.aspx.cc/'><img src='http://dotnet.aspx.cc/Images/logoSite.gif' border='0' /></a>";
d2.Start();
</script>
</body>
</html>
PChelp 2011-05-10
  • 打赏
  • 举报
回复
调用JS代码呀.
PChelp 2011-05-10
  • 打赏
  • 举报
回复
调用JS代码就可以了呀.
PChelp 2011-05-10
  • 打赏
  • 举报
回复
调用JS代码
孟子E章 2011-05-08
  • 打赏
  • 举报
回复
这跟asp没有任何关系,asp是在服务器端运行的。

28,403

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧