アプリ版:「スタンプのみでお礼する」機能のリリースについて

お世話になります。
AというWEBページ
textarea-1 textarea-2
textarea-3 textarea-4
「ボタン」

上記のtextarea4つの内容を「ボタン」を押したらそっくり
BというWEBページのテキストエリアにペーストするにはどうしたらいいでしょうか。
textarea-1 textarea-2
textarea-3 textarea-4

A 回答 (2件)

こんな感じですかねー。


PageAのボタンを押すと、別に開いてあるPageB(親子関係無し)のTextArea3にPageAのTextArea1のデータが入ります。
あとはこれを改良してみてください。

-PageA--------------------------------------------------------------------------------------
<html>
<head>
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function Button1_onclick() {
var win = window.open("", "page2");
var objTextarea = win.document.getElementsByName('TextArea3')[0];
var objTextarea2 = document.getElementsByName('TextArea1')[0];
objTextarea.value = objTextarea2.value;
}
</script>
</head>
<body>
<textarea id="TextArea1" cols="20" rows="2"></textarea>
<textarea id="TextArea2" cols="20" rows="2"></textarea>
<br />
<input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />
</body>
</html>


-PageB--------------------------------------------------------------------------------------
<html>
<head>
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">

function body_onLoad() {
window.name="page2";
confirm(window.name);
}

</script>
</head>
<body onload="return body_onLoad()">
<textarea id="TextArea3" cols="20" rows="2"></textarea>
<textarea id="TextArea4" cols="20" rows="2"></textarea>
</body>
</html>
    • good
    • 0
この回答へのお礼

大変ご親切にご回答いただき、誠にありがとうございました。
参考にさせていただきます。

お礼日時:2009/11/16 10:22

ちょっと改造して、AページとBページの親子関係が有る場合のサンプル


Bページは予め開いてなくても良いけど、Aページは閉じちゃだめのパターンです。
(Aページ)======
<script type="text/javascript">
<!--
var win;
function Button1_onclick() {
win = window.open("http://xxxx/Bページ.htm");
}
// -->
</script>
</head>
<body>
<textarea name="TextArea1" cols="20" rows="2"></textarea>
<textarea name="TextArea2" cols="20" rows="2"></textarea>
<br />
<input id="Button1" type="button" value="openで開く" onclick="Button1_onclick();" />
<br><a href="http://xxxx/Bページ.htm" target="_blank">リンクで開く</a>
</body>
</html>
(Bページ)======
<script type="text/javascript">
<!--
window.onload = function () {
var moto=(window.opener)?window.opener.document.location : window.document.referrer;
if(moto=='http://xxxx/Aページ.htm'){
document.getElementsByName('TextArea3')[0].value
=(window.opener)?window.opener.document.getElementsByName('TextArea1')[0].value:
document.referrer.window.document.getElementsByName('TextArea1')[0].value;
document.getElementsByName('TextArea4')[0].value
=(window.opener)?window.opener.document.getElementsByName('TextArea2')[0].value:
document.referrer.window.document.getElementsByName('TextArea2')[0].value;
}
}
// -->
</script>
</head>
<body>
<textarea name="TextArea3" cols="20" rows="2"></textarea>
<textarea name="TextArea4" cols="20" rows="2"></textarea>
</body>
</html>
    • good
    • 0
この回答へのお礼

大変ご親切にご回答いただき、誠にありがとうございました。
参考にさせていただきます。

お礼日時:2009/11/16 10:23

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!