入力に iframe-in 値を入力したい。
私は2つのhtmlファイルを持っています。1.html と 2.html
最初のもの (1.html) は次のようになります。
<html>
<head>
<title>IFRAME TEST</title>
</head>
<body>
<input type="text" value="" id="mylovelytextbox"><br />
<iframe src="2.html" id="mylovelyiframe">
</body>
</html>
2 つ目 (2.html) は次のようになります。
<html>
<head>
<form method="get" action="">
<input type="hidden" name="thisone" value="mylovelychangedvalue">
</form>
</body>
</html>
1.html の mylovelytextbox を thisone の値で埋めたいです。どうやってやるの?-下手な英語でごめんなさい:(
編集:
@stano の助けを借りてコードを実行します :) 今、私のコードは次のようになります。
<html> <head> <title>IFRAME TEST</title> </head> <body> <input type="text" value="" id="mylovelytextbox"><input type="button" onClick="var iframe = document.getElementById('mylovelyiframe');console.log(iframe,doc,el);var doc = iframe.contentDocument || iframe.contentWindow.document;var el = document.getElementById('mylovelytextbox');el.value = doc.getElementsByName('thisone')[0].value;" value="Click"><br /> <iframe sandbox="allow-same-origin allow-scripts" src="2.html" id="mylovelyiframe"></iframe> </body> </html>
どうもありがとう、スタノ!