このコードは、テキストエリアにテキストを挿入できません。以下の html を参照してください。このスニペットは実際の Web ページを模倣しているため、html を変更できません。テキストエリアにテキストを挿入するだけです。
Chrome や IE9 では動作しません。
何か案は?
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<script type="text/javascript">
function insert_text() {
//enumerate div sections and find where id = WIN_0_4
var div = window.document.getElementById("WIN_0_4");
if(div !== null)
{
var txtbox = div.getElementsByTagName('textarea');
if(txtbox !== null)
txtbox.value = document.frm.texttoinsert.value;
}
}
</script>
<form name="frm">
<input type="button" id="clicker" value="Click me" />
<input type="button" value="insert" id="inserter" onclick="insert_text();" />
<input type="text" name="texttoinsert" />
</form>
<div id="WIN_0_536870917" arid=536870917 artype="View" ardbn="View Field2" class="arfid536870917 ardbnViewField2" style="color:#0000FF">
some text here
</div>
<div id="WIN_0_4" arid=4 artype="Char" ardbn="Assigned To">
<label id="label4" class="label f6">Assigned To</label>
<textarea class="text sr " wrap="off" id="arid_WIN_0_4" cols="20" maxlen=254 arautocak=0 arautoctt=400 rows=1></textarea>
</div>
</body>
</html>