Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

html iframe and JS contentwindow

var x = document.getElementsByTagName("iframe")[0].contentWindow;
//x = window.frames[0];

x.document.getElementsByTagName("body")[0].style.backgroundColor = "blue";
// this would turn the 1st iframe in document blue.
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

apply css to iframe content javascript

<script>
    setInterval(function(){
      document.getElementById("iframeId").classList.add('your-class')
    },500);
  </script>

Now you need to write css code with your class name. Thank you
Comment

js set iframe code

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

js change iframe content

$(iframeSelector).contents().find('html').html(htmlContent);
Comment

js change iframe content

<iframe src="javascript:void(0);"></iframe>
Comment

PREVIOUS NEXT
Code Example
Javascript :: innertext 
Javascript :: even or odd in javascript 
Javascript :: python append to json file 
Javascript :: convert a string into an integer 
Javascript :: themein material ui 
Javascript :: convert int to timestanp js 
Javascript :: debounce events in js 
Javascript :: javascript array group by id 
Javascript :: url query example 
Javascript :: javascript ternary operator 
Javascript :: jquery validation focus field on error 
Javascript :: axios fainally 
Javascript :: javascript cheat sheet pdf 
Javascript :: delete all the fields on the form whit jquery 
Javascript :: convert an array to uppercase or lowercase js 
Javascript :: javascript textarea autosize 
Javascript :: parse json to dart model 
Javascript :: compare mongoose id 
Javascript :: find common characters in two strings javascript 
Javascript :: delete in javascript 
Javascript :: Javascript load at Window loading time 
Javascript :: check box jquery 
Javascript :: moment.js 
Javascript :: change js 
Javascript :: how to get all attributes of an element in jquery 
Javascript :: how to pass data in body of delete request angular 
Javascript :: regex.match 
Javascript :: script src= https//kit.fontawesome.com/a81368914c.js /script 
Javascript :: js push array to array 
Javascript :: sequelize mariadb example 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =