Answers for "iframe set value on input outside js"

0

iframe set value on input outside js

<body>
    <input id="input-field" />
</body>
Posted by: Guest on November-18-2020
0

iframe set value on input outside js

<body>
    <iframe id="site2-frame" src="http://www.mysite2.com/index.php"></iframe>
</body>
Posted by: Guest on November-18-2020
0

iframe set value on input outside js

var frame = document.getElementById('site2-frame');

frame.contentWindow.postMessage('Something something something', '*');
Posted by: Guest on November-18-2020
0

iframe set value on input outside js

var input = document.getElementById('input-field');

window.addEventListener('message', function(e) {
    // Check the origin, accept messages only if they are from YOUR site!
    if (/^http\:\/\/www\.mysite1\.com/.test(e.origin)) {
        input.value = e.data; 
        // This will be 'Something something something'
    }
});
Posted by: Guest on November-18-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language