100分 document.execCommand("paste",0,str)命令 <input value=点击粘贴到这里 onclick="document.execCommand('paste',0,'1231')"> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 freefalcon: 请详细说说,给段代码看看bencalie:我现在情况是:有时候可以有时候粘贴不上,不知道什么原因一定给分。thanks 我现在是在a.html这样一个javascript方法 function enterName(name) { document.form1.name.focus(); document.execCommand('paste',0,name); }然后这个a.html里插入了一个iframe<div width="100%"><iframe name="b" src="b.html" frameborder="0" width="100%" height="850" border="0"></iframe></div>在这个b.html 里面这样调用a.html里的方法 <td class="table3" width="8%" style="cursor:hand" onclick="javascript:parent.enterName('aaaaaa')">这样做的目的是:把b.html的值粘贴到a.html里的一个输入框中。然后出现在的现象是:同样的代码,在同一台机器上有时候可以粘贴上去,有时候不行。(换一个机器有时候可以,有时候也不行)如果当时不能粘贴的机器,过了一会又可以了。发生这些情况的时候,代码、机器环境都没有改变,所以很困惑整体来说,可以粘贴上去的情况居多。 <body><script>function enterName(name) { eval("document.form1."+name).focus(); document.execCommand('paste',0,name); }</script><div width="100%"><iframe name="b" src="temp.htm" frameborder="1" width="100%" height="50" border="0"></iframe></div><form name=form1><input type=text name="aaaaaa"></form></body>temp.htm============<input type="button" value="Click here" class="table3" width="8%" style="cursor:hand" onclick="javascript:parent.enterName('aaaaaa')"> eval("document.form1."+name).focus(); ????我这里的document.form1.name 是随手写的,现在改一下, function enterName(name) { document.form1.noname.focus(); document.execCommand('paste',0,name); }这里传进的参数和和输入框没有任何关系,不知道我理解对你的意思对没有,请在麻烦看一下,如解决,奉送200分。不能解决也有分送thanks document.execCommand('paste',0,name);=>document.selection.createRange().text=name; 刚才是我误解了,我试过document.execCommand('paste',0,name);,不存在问题。秋水的方法也是可以的 我的问题已经解决了,原因很奇怪,是和winodws的剪贴板有关,当剪贴板里的没有内容时,document.execCommand('paste',0,name) 就失效。发现原因后,用window.clipboardData.setData("TEXT","something"),往剪贴板里写数据,至此问题解决。感谢大家的积极参与。给分。:) js问题 分层现实 JS变量传值~~~~~~~~急 提个有意思的问题 使用javaScript做了个列表菜单,有个简单的问题,在线等 js如何判断字符串是否包含某些特定的中文字符 救命!表格简单问题!在线等! offsetLeft得到的值的单位能不能是CM 做过IE浏览器中打印功能的高手请入内!!! 谁能帮助我:在页面关闭的时候,如何给出提示.你是否关闭该页面? 如何实现在showmodeldialog()弹出的窗口中提交form但不弹出新窗口。 IE中有一个点连接的URL是一个EXE文件,怎样在点下这个连接时直接运行这个EXE而不是弹出下载对话框? 谁可以帮我这个啊?(在线等你哦!!!)
bencalie:我现在情况是:有时候可以有时候粘贴不上,不知道什么原因
一定给分。thanks
function enterName(name)
{
document.form1.name.focus();
document.execCommand('paste',0,name);
}然后这个a.html里插入了一个iframe
<div width="100%"><iframe name="b" src="b.html" frameborder="0" width="100%" height="850" border="0"></iframe></div>
在这个b.html 里面这样调用a.html里的方法 <td class="table3" width="8%" style="cursor:hand" onclick="javascript:parent.enterName('aaaaaa')">这样做的目的是:把b.html的值粘贴到a.html里的一个输入框中。
然后出现在的现象是:
同样的代码,在同一台机器上有时候可以粘贴上去,有时候不行。(换一个机器有时候可以,有时候也不行)
如果当时不能粘贴的机器,过了一会又可以了。发生这些情况的时候,代码、机器环境都
没有改变,所以很困惑整体来说,可以粘贴上去的情况居多。
<script>
function enterName(name)
{
eval("document.form1."+name).focus();
document.execCommand('paste',0,name);
}
</script>
<div width="100%"><iframe name="b" src="temp.htm" frameborder="1" width="100%" height="50" border="0"></iframe></div>
<form name=form1>
<input type=text name="aaaaaa">
</form>
</body>temp.htm
============
<input type="button" value="Click here" class="table3" width="8%" style="cursor:hand" onclick="javascript:parent.enterName('aaaaaa')">
{
document.form1.noname.focus();
document.execCommand('paste',0,name);
}这里传进的参数和和输入框没有任何关系,不知道我理解对你的意思对没有,
请在麻烦看一下,如解决,奉送200分。不能解决也有分送thanks
=>
document.selection.createRange().text=name;
发现原因后,用window.clipboardData.setData("TEXT","something"),往剪贴板里写数据,至此问题解决。感谢大家的积极参与。给分。:)