Rolinson's Blog

ASP.NET , J2ME , WAP
(还有收藏网络上的技术文章,以便一急之用)

博客园 首页 新随笔 联系 订阅 管理

一、实现动态创建元素,并把元素内容复制到粘贴板上。
function CreateElementToCopyValue(val)
{
    var tt = document.createElement("input");
    tt.type = "text";
    tt.value = val;
    document.body.appendChild(tt);
    tt.createTextRange().select(); 
    document.selection.createRange().execCommand("Copy"); // Or "Paste"
}


二、复制指定控件上的内容到粘贴板上。
<input id="copytxt" type="text" value="" size="50"><input type="button" value="点击复制地址" onclick="copyit()">

<script>
document.getElementById('copytxt').value = document.URL;
function copyit()
{
 var obj = document.getElementById('copytxt');
 obj.select();
 var js = obj.createTextRange();
 js.execCommand("Copy");
 alert("复制成功!");
}
</script>


三、获取键盘按键。
window.event.keyCode


四、禁止右键播放器 Realplay。
<body onload="initPlayer()">
<script language="javascript">
function initPlayer()
{
document.player.SetWantMouseEvents(true)
}
function noRB()
{
setTimeout("alert('右键禁止')",400)
}
</script>
<script language="vbscript">
sub player_OnRButtonDown(ByVal nFlags, ByVal nX, ByVal nY)
 if player.getfullscreen() then
  player.SetOriginalSize()
  noRB()
 else
  msgbox("右键禁止")
 end if
End Sub
</script>


五、按回车键直接代替Tab键
function document.onkeydown()
{
  if(event.keyCode==13 && event.srcElement.type !="BUTTON" && event.srcElement.type!="SUBMIT")
   event.keyCode=9;
}

//和按 Tab 键的效果一样

posted on 2005-06-03 15:34  ByNow  阅读(1962)  评论(3编辑  收藏  举报