大侠请帮忙! 呵呵,那你要在刚才的那个JS函数基础上加一个一些事件啊比如img.onclick=function(){alert(1)}这样你就有一个点击的事件了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你要拖动? 我这里有一个拖动类:/* Auth: jingliangliang Date: 2008-5-5 Email: [email protected]*/(function(){ if(typeof Drag != "undefined") { var _Drag = Drag; } //此处声明Drag类 //--elementid:要移动元素的ID var Drag = window.Drag = function(elementid){ var thisDrag = this; this.DifWidth = 0; this.DifHeight = 0; this.thisDivDrag = document.getElementById(elementid); this.thisDivDrag.onmousedown = function(event){ var theevent; var theSrcevent; if(window.event) { theevent = window.event; theSrcevent = window.event.srcElement; } else { theevent =event; theSrcevent =event.target; } thisDrag.DifWidth= theevent.clientX - theSrcevent.offsetLeft; thisDrag.DifHeight = theevent.clientY - theSrcevent.offsetTop; document.body.onmousemove =function(event){ var theevent; if(window.event) { theevent = window.event; } else { theevent =event; } thisDrag.thisDivDrag.style.left = theevent.clientX -thisDrag.DifWidth ; thisDrag.thisDivDrag.style.top = theevent.clientY -thisDrag.DifHeight ; }; document.body.onmouseup =function(event) { document.body.onmousemove = ""; }; }; };})();====实现方法:放一个js然后引用,window.onload=function(){ __Drag = new Drag("div1");}; <!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><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title><script>function showifra(){var img =window.frames["ifra"].document.createElement('img'); img.src="loading.gif";img.id="img1";img.style.position="absolute";img.onmousemove=moveImage; window.frames["ifra"].document.getElementById("img").appendChild(img)}function moveImage(){ window.frames["ifra"].document.getElementById("img1").style.left=200+"px"; window.frames["ifra"].document.getElementById("img1").style.top=100+"px"; }</script></head><body><iframe id="ifra" name="ifra" src="13.asp" width="600" height="500"></iframe><input type="image" onclick="showifra()" src="loading.gif"/></body></html>我只给你一个简单的例子你自己再扩展 moveImage这个函数即可 form js jq ajax 的问题 JS读取COOKIES jsp页面填充数据问题 员工工资管理系统中的工资管理 frameset之间函数调用 悬浮div始终为何不能固定在页面的中间 请问如何在刷新A页面的时候关闭B页面 请问那种没有任何边框的窗体如何实现?我以前见过有人用它做过拟qq,现在找不着了 如何让一个在<DIV>中的很长的表格的第一行的位置固定不变??? 能否获得随机整数? 缺少对象. 如何让div里面的内容,能够看见,但是点不着
我这里有一个拖动类
:
/*
Auth: jingliangliang
Date: 2008-5-5
Email: [email protected]
*/
(function(){
if(typeof Drag != "undefined")
{
var _Drag = Drag;
}
//此处声明Drag类
//--elementid:要移动元素的ID
var Drag = window.Drag = function(elementid){
var thisDrag = this;
this.DifWidth = 0;
this.DifHeight = 0;
this.thisDivDrag = document.getElementById(elementid);
this.thisDivDrag.onmousedown = function(event){
var theevent;
var theSrcevent;
if(window.event)
{
theevent = window.event;
theSrcevent = window.event.srcElement;
}
else
{
theevent =event;
theSrcevent =event.target;
}
thisDrag.DifWidth= theevent.clientX - theSrcevent.offsetLeft;
thisDrag.DifHeight = theevent.clientY - theSrcevent.offsetTop;
document.body.onmousemove =function(event){
var theevent;
if(window.event)
{
theevent = window.event;
}
else
{
theevent =event;
}
thisDrag.thisDivDrag.style.left = theevent.clientX -thisDrag.DifWidth ;
thisDrag.thisDivDrag.style.top = theevent.clientY -thisDrag.DifHeight ;
};
document.body.onmouseup =function(event)
{
document.body.onmousemove = "";
};
};
};
})();
====实现方法:
放一个js然后引用,window.onload=function(){
__Drag = new Drag("div1");
};
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script>
function showifra()
{
var img =window.frames["ifra"].document.createElement('img');
img.src="loading.gif";
img.id="img1";
img.style.position="absolute";
img.onmousemove=moveImage;
window.frames["ifra"].document.getElementById("img").appendChild(img)
}
function moveImage(){
window.frames["ifra"].document.getElementById("img1").style.left=200+"px";
window.frames["ifra"].document.getElementById("img1").style.top=100+"px";
}
</script>
</head><body>
<iframe id="ifra" name="ifra" src="13.asp" width="600" height="500"></iframe>
<input type="image" onclick="showifra()" src="loading.gif"/>
</body>
</html>我只给你一个简单的例子
你自己再扩展 moveImage这个函数即可