Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

iframe getelementbyid

document.getElementById('myframe1').contentWindow.document.getElementById('x')
Comment

how to get element in iframe using javascript

const iframe = document.getElementById("myIframe");

const iWindow = iframe.contentWindow;
const iDocument = iWindow.document;

// accessing the element
const element = iDocument.getElementsByTagName("p")[0];
element.style.color = "green";
Comment

use javascript to control iframe elements

<iframe id="myIFrame" src="thispage.html"
    width="100%" height="600"
    frameBorder="2">
</iframe>

// Get the iframe
const iFrame = document.getElementById('myIFrame');

// Let's say that you want to access a button with the ID `'myButton'`,
// you can access via the following code:
const buttonInIFrame = iFrame.contentWindow.document.getElementById('myButton');

// If you need to call a function in the iframe, you can call it as follows:
iFrame.contentWindow.yourFunction();
Comment

js set iframe src

<script type="text/javascript">
function iframeDidLoad() {
    alert('Done');
}

function newSite() {
    var sites = ['http://getprismatic.com',
                 'http://gizmodo.com/',
                 'http://lifehacker.com/']

    document.getElementById('myIframe').src = sites[Math.floor(Math.random() * sites.length)];
}    
</script>
<input type="button" value="Change site" onClick="newSite()" />
<iframe id="myIframe" src="http://getprismatic.com/" onLoad="iframeDidLoad();"></iframe>
Comment

js set iframe code

var html_string= "content";
document.getElementById('output_iframe1').src = "data:text/html;charset=utf-8," + escape(html_string);
Comment

PREVIOUS NEXT
Code Example
Javascript :: change browser image react 
::  
::  
Javascript :: javascript loop over classes 
Javascript :: @angular/common 
::  
::  
::  
::  
Javascript ::  
::  
Javascript ::  
::  
::  
Javascript ::  
::  
::  
Javascript ::  
:: nuxt redirect traffic from http to https 
::  
Javascript :: javascript fillstyle 
Javascript ::  
::  
Javascript ::  
::  
:: nextjs socket.io 
::  
::  
Javascript ::  
Javascript ::  
ADD CONTENT
Topic
Content
Source link
Name
8+8 =