MagicPlayer 网络流媒体播放器可以用鼠标在浏览器页面内拖放,具体页面代码如下:
方法一:(兼容 IE、Firefox 支持 W3C XHTML 标准)
<html>
<head>
<title>MagicPlayer 网页拖放 兼容 IE、Firefox 支持 W3C XHTML 标准</title>
</head>
<body>
<script type="text/javascript">
<!--
var isIE = (document.all) ? true : false;
var $ = function (id) {
return "string" == typeof id ? document.getElementById(id) : id;
};
var Class = {
create: function() {
return function() { this.initialize.apply(this, arguments); }
}
}
var Extend = function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
}
var Bind = function(object, fun) {
return function() {
return fun.apply(object, arguments);
}
}
var BindAsEventListener = function(object, fun) {
return function(event) {
return fun.call(object, (event || window.event));
}
}
function addEventHandler(oTarget, sEventType, fnHandler) {
if (oTarget.addEventListener) {
oTarget.addEventListener(sEventType, fnHandler, false);
} else if (oTarget.attachEvent) {
oTarget.attachEvent("on" + sEventType, fnHandler);
} else {
oTarget["on" + sEventType] = fnHandler;
}
};
function removeEventHandler(oTarget, sEventType, fnHandler) {
if (oTarget.removeEventListener) {
oTarget.removeEventListener(sEventType, fnHandler, false);
} else if (oTarget.detachEvent) {
oTarget.detachEvent("on" + sEventType, fnHandler);
} else {
oTarget["on" + sEventType] = null;
}
};
var magicdrag = Class.create();
magicdrag.prototype = {
initialize: function(drag) {
this.Drag = $(drag);
this.x = this.y = 0;
this.fM = BindAsEventListener(this, this.Move);
this.fS = Bind(this, this.Stop);
this.Drag.style.position = "absolute";
addEventHandler(this.Drag, "mousedown", BindAsEventListener(this, this.Start));
},
Start: function(oEvent) {
this.x = oEvent.clientX - this.Drag.offsetLeft;
this.y = oEvent.clientY - this.Drag.offsetTop;
addEventHandler(document, "mousemove", this.fM);
addEventHandler(document, "mouseup", this.fS);
},
Move: function(oEvent) {
this.Drag.style.left = oEvent.clientX - this.x + "px";
this.Drag.style.top = oEvent.clientY - this.y + "px";
},
Stop: function() {
removeEventHandler(document, "mousemove", this.fM);
removeEventHandler(document, "mouseup", this.fS);
}
};
////-->
</script>
<div id="magic" style="left:580px; top:250px; position:absolute; z-index:1; cursor:move;">
<center style="background-color:#C3D9FF; font-weight:bold; line-height:30px;">MagicPlayer</center>
<object width="400" height="340" id="magicplayer" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" align="middle">
<param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="quality" value="high" />
<param name="scale" value="noscale" /><param name="play" value="false" /><param name="bgcolor" value="#000000" />
<param name="movie" value="http://www.magicplayer.net.cn/magicplayer.swf?file=http://flv.uurain.cn/magic.flv&" />
<embed src="http://www.magicplayer.net.cn/magicplayer.swf?file=http://flv.uurain.cn/magic.flv&" width="400" height="340" name="magicplayer" play="false" quality="high" scale="noscale" bgcolor="#000000" align="middle" wmode="transparent" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</div>
<script>new magicdrag("magic");</script>
</body>
</html>
方法二:
<html>
<head>
<title>MagicPlayer 网页拖放</title>
<head>
<body>
<script language="javascript" type="text/javascript">
<!--
function magicmove(id){
this.obj=MOT(id);
this.offsetX=0;
this.offsetY=0;
this.mousemove=function(){
var e=window.event;
if(e.button!=1)return false;
var top =e.clientY;
var left=e.clientX;
this.obj.style.left=left-this.offsetX;
this.obj.style.top =top -this.offsetY;
}
this.mousedown=function(){
var e=window.event;
this.offsetY=e.clientY-parseInt(this.obj.style.top);
this.offsetX=e.clientX-parseInt(this.obj.style.left);
} }
function magicobject(id){return document.getElementById(id);}
////-->
</script>
<div id="magic" style="position:absolute; left:600px; top:250px; z-index:1; cursor:move;" align="center" onMousedown="magicmove.mousedown();return false;" onMouseMove="magicmove.mousemove();return false;" >
<center style="background-color:#C3D9FF; font-weight:bold; line-height:30px;">MagicPlayer</center>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="400" height="340" id="magicplayer" align="middle">
<param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="quality" value="high" />
<param name="scale" value="noscale" /><param name="play" value="false" /><param name="bgcolor" value="#000000" />
<param name="movie" value="http://www.magicplayer.net.cn/magicplayer.swf?file=http://flv.uurain.cn/magic.flv&" />
<embed src="http://www.magicplayer.net.cn/magicplayer.swf?file=http://flv.uurain.cn/magic.flv&" width="400" height="340" name="MagicPlayer" play="false" quality="high" scale="noscale" bgcolor="#000000" align="middle" wmode="transparent" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</div>
<script>var magicmove=new magicmove("magic");</script>
</body>
</html>