[英]Take a value from textarea then paste it in another windows?
i want to get a value of textarea then open a new window that contains another textarea and paste the value there using javascript . 我想获取一个textarea值,然后打开一个包含另一个textarea的新窗口,然后使用javascript将值粘贴在那里。
i tried that with fail , any hint ? 我尝试失败了,有什么提示吗?
function sharex() {
var post = document.getElementById('msgxvmid').value;
window.open('http://www.google.com' , document.getElementById('vB_Editor_QR_textarea').value = post);
}
EDIT : i want to do that on the same site with another page (Google link is just an example) 编辑 :我想在同一个站点的另一个页面上执行此操作(Google链接只是一个示例)
Javascript would probably not be the best way to do this, but if you only want to do this internally, here's a solution: Javascript可能不是执行此操作的最佳方法,但是如果您只想在内部执行此操作,则可以采用以下解决方案:
On your first page, open the window and add a parameter behind the URL with the text you want to paste on the other page, for example 在您的第一页上,打开窗口,然后在URL后面添加一个参数,其中要粘贴的文本将显示在另一页上,例如
window.open('otherpage.html?post=this is the pasted value');
On the other page otherpage.html
in this example you retrieve the parameter's value from the url: 在此示例的另一页
otherpage.html
,您从URL中检索参数的值:
var url = new String(decodeURI(window.location));
var post = url.match(/\?post=(.+)/)[1];
(In this example the parameter name has to be post to get the value, but you can modify the regex to match as many parameters as you want). (在这个例子中,参数名称必须是后得到的数值,但可以修改正则表达式,你想匹配的许多参数)。
Also add a function to change the contents of your vB_Editor_QR_textarea
还添加一个函数来更改
vB_Editor_QR_textarea
的内容
function setValues()
{
document.getElementById('vB_Editor_QR_textarea').value = post;
}
And of course call this function when the body loads 当然,当身体负荷时调用此函数
<body onload="setValues()">
<textarea id="vB_Editor_QR_textarea"></textarea>
</body>
Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.