사용자 스크립트를 사용하여 목표를 달성 할 수 있습니다. 나는 examone siteone.com을 만들었다 - 입력, 버튼, iframe이있는 페이지 (sitetwo.com을 본다). 버튼을 클릭하면 siteone.com의 입력 값이 sitetwo.com의 입력 값으로 표시됩니다. 사용자 스크립트를 설치하려면 Chrome 및 Safari 용 브라우저 확장 Tampermonkey 또는 Firefox 용 Greasemonkey를 사용할 수 있습니다. 페이지와 iframe 사이의 통신을 위해 Window.postMessage를 사용했습니다. documentation입니다. 자바 스크립트 라이브러리가 필요한 경우 @require 메타 블록 link을 사용할 수 있습니다.
siteone.com index.html을
<html>
<head>
</head>
<body>
<input id="parent-input" type="text"/>
<button id="send-data-to-iframe">Send data to iframe</button>
<br /><br />
<iframe id="my-iframe" style="border:1px solid red; height:50px; width:200px;" src="http://sitetwo.com:8080">
</iframe>
<script>
var win = document.getElementById("my-iframe").contentWindow;
document.getElementById("send-data-to-iframe").onclick = function(){
win.postMessage(
document.getElementById("parent-input").value,
"http://sitetwo.com:8080" // target domain
);
return false;
}
</script>
</body>
sitetwo.com index.html을
<html>
<head>
</head>
<body>
<input id="iframe-input" type="text"/>
</body>
myUserJS.user.js
무슨 뜻 이죠
// ==UserScript==
// @name myUserJS
// @license MIT
// @version 1.0
// @include http://sitetwo.com*
// ==/UserScript==
(function (window, undefined) {
var w;
if (typeof unsafeWindow != undefined) {
w = unsafeWindow
} else {
w = window;
}
// extended check, sometimes @include section is ignored
if (/http:\/\/sitetwo.com/.test(w.location.href)) {
function listener(event){
document.getElementById("iframe-input").value = event.origin + " send: " + event.data;
}
if (w.addEventListener){
w.addEventListener("message", listener,false);
} else {
w.attachEvent("onmessage", listener);
}
}
})(window);
by "폼에서 값을 맵핑하여 nother form "? 첫 번째 양식을 수동으로 채우고 두 번째 양식에 값을 복사 하시겠습니까? – abl
정확히, site1.com의 양식은 사용자가 아닌 나를 입력해야합니다. 제출 후 양식을 볼 때이 세부 정보는 site2.com의 다른 양식으로 복사해야합니다. – apfz