{"id":13066,"date":"2016-06-08T16:15:08","date_gmt":"2016-06-08T13:15:08","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=13066"},"modified":"2018-01-10T16:30:11","modified_gmt":"2018-01-10T14:30:11","slug":"javascript-frame-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/","title":{"rendered":"Javascript Frame Example"},"content":{"rendered":"<p>The aim of this tutorial is to describe and demonstrate using JavaScript to manipulate and interact with iframes, showing how to access and modify properties of the iframe element, how to communicate with the document inside the iframe, getting information from the iframe and passing information to it.<\/p>\n<p>Iframes, or inline frames, allow you to load separate HTML files into an existing document.Iframes can be placed anywhere in the html document.<\/p>\n<p>JavaScript can be used to manipulate the appearance and properties of the iframe element , its position, size, and src, for example. JavaScript can also be used to pass data between the html document containing the iframe and the iframe itself.<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;tCIwOngQUb3zSUuF&#8217;]<\/p>\n<h2>1. HTML<\/h2>\n<p>First of all you need to create two simple html documents.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>iframeExample.html<\/em><\/span><\/p>\n<pre class=\"brush:xml;\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n\t&lt;title&gt;Javascript IFrame Example&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h2>2. Javascript IFrame Example<\/h2>\n<h3>2.1 Change iframe src by using javascript<\/h3>\n<p>Let us add the following html code to our page.<\/p>\n<pre class=\"brush:xml;highlight:[2]\">&lt;div&gt;\r\n\t&lt;iframe id=\"ifrm\" src=\"https:\/\/www.webcodegeeks.com\/\" width=\"500\" height=\"300\"&gt;&lt;\/iframe&gt;\r\n&lt;\/div&gt;\r\n&lt;div&gt;\r\n\t&lt;a href=\"javascript:retrun 0;\" onclick=\"changeIframePro()\"&gt;change iframe src&lt;\/a&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>You can get a reference to an iframe using <code>getElementById()<\/code>. You can use that reference to set properties on the iframe, such as style,src and so on.<\/p>\n<pre class=\"brush:js;highlight:[5,6]\">&lt;script type=\"text\/javascript\"&gt;\r\n\r\nfunction changeIframePro(){\r\n\t\/\/ reference to iframe with id 'ifrm'\r\n\tvar ifrm = document.getElementById('ifrm');\r\n\tifrm.src = 'http:\/\/www.iliastsagklis.com\/'; \/\/ set src to new url\r\n}\r\n\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>The result in the browser would be:<\/p>\n<figure id=\"attachment_13073\" aria-describedby=\"caption-attachment-13073\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/06\/javascriptIframeExample1.gif\"><img decoding=\"async\" class=\"size-full wp-image-13073\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/06\/javascriptIframeExample1.gif\" alt=\"Chnage iframe src by using javascript\" width=\"800\" height=\"350\" \/><\/a><figcaption id=\"caption-attachment-13073\" class=\"wp-caption-text\">Change iframe src by using javascript<\/figcaption><\/figure>\n<h3>2.2 Access to Iframe and its Document and Content<\/h3>\n<p>The buttons in the following html code will access the iframe data by using contentWindow and contentDocument properties.<\/p>\n<pre class=\"brush:xml;highlight:[5,6,7,8,13]\">&lt;h1&gt;Accessing an Iframe and its Document and Content&lt;\/h1&gt;\r\n&lt;p&gt;This example demonstrates the containing document interacting with the iframe.&lt;\/p&gt;\r\n&lt;form id=\"demoForm\" action=\"#\"&gt;\r\n    &lt;p&gt;\r\n        &lt;input name=\"button1\" type=\"button\" value=\"Button 1\" onclick=\"button1Handler()\"\/&gt;\r\n        &lt;input name=\"button2\" type=\"button\" value=\"Button 2\" onclick=\"button2Handler()\"\/&gt; \r\n        &lt;input name=\"button3\" type=\"button\" value=\"Button 3\" onclick=\"button3Handler()\"\/&gt; \r\n        &lt;input name=\"button4\" type=\"button\" value=\"Button 4\" onclick=\"button4Handler()\"\/&gt; \r\n    &lt;\/p&gt;\r\n    &lt;p&gt;&lt;input type=\"text\" name=\"display\" size=\"30\" readonly=\"readonly\" \/&gt;&lt;\/p&gt;\r\n&lt;\/form&gt;\r\n\r\n&lt;iframe name=\"ifrm\" id=\"ifrm\" src=\"iframed.html\" width=\"450\" height=\"250\"&gt;&lt;\/iframe&gt;\r\n<\/pre>\n<p>The iframe element provides contentWindow and contentDocument properties. The following JavaScript uses these properties to get references to the iframed document&#8217;s window and document objects. Once you have references to the window and document objects, you can access virtually any object or property in the iframed document and can access it&#8217;s javascript varibales and methods.<\/p>\n<pre class=\"brush:js;highlight:[8,9,16,17,26,28,36,37]\">&lt;script type=\"text\/javascript\"&gt;\r\n\r\n    \/\/ get reference to the form \r\n    var form = document.getElementById('demoForm');\r\n    \r\n    \/\/ set height of iframe and display value\r\n    function button1Handler(){\r\n        var ifrm = document.getElementById('ifrm');\r\n        var ht = ifrm.style.height = '200px';\r\n        form.display.value = 'The iframe\\'s height is: ' + ht;\r\n    }\r\n    \r\n    \/\/ increment and display counter variable contained in iframed document\r\n    function button2Handler() {\r\n        \/\/ get reference to iframe window\r\n        var win = document.getElementById('ifrm').contentWindow;\r\n        var counter = ++win.counter; \/\/  increment\r\n        form.display.value = 'counter in iframe is: ' + counter;\r\n    }\r\n    \r\n    \/\/ reference form element in iframed document\r\n    function button3Handler() {\r\n        \r\n        var ifrm = document.getElementById('ifrm');\r\n        \/\/ reference to document in iframe\r\n        var doc = ifrm.contentDocument? ifrm.contentDocument: ifrm.contentWindow.document;\r\n        \/\/ get reference to greeting text box in iframed document\r\n        var fld = doc.forms['iframeDemoForm'].elements['greeting'];\r\n        var val = fld.value;\r\n        \/\/ display value in text box\r\n        form.display.value = 'The greeting is: ' + val;\r\n    }\r\n    \r\n    function button4Handler(){\r\n        \/\/ get reference to iframe window\r\n        var win = document.getElementById('ifrm').contentWindow;\r\n        win.clearGreeting(); \/\/ call function in iframed document\r\n    }\r\n\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>The result in the browser would be:<\/p>\n<figure id=\"attachment_13094\" aria-describedby=\"caption-attachment-13094\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/06\/javascriptIframeExample22.gif\"><img decoding=\"async\" class=\"size-full wp-image-13094\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/06\/javascriptIframeExample22.gif\" alt=\"Access to Iframe and its Document and Content\" width=\"800\" height=\"390\" \/><\/a><figcaption id=\"caption-attachment-13094\" class=\"wp-caption-text\">Access to Iframe and its Document and Content<\/figcaption><\/figure>\n<h3>2.3 JavaScript Interaction between Iframe and Parent<\/h3>\n<p>First of all add the following html code to the <span style=\"text-decoration: underline;\"><em>iframeExample.html<\/em><\/span> page.<\/p>\n<pre class=\"brush:xml;highlight:[3]\">&lt;h1&gt;References from Iframed Document to its Parent&lt;\/h1&gt;\r\n&lt;p&gt;This example demonstrates access from iframed document to containing document.&lt;\/p&gt;\r\n&lt;iframe name=\"ifrm\" id=\"ifrm\" src=\"parented.html\" width=\"450\" height=\"250\"&gt;&lt;\/iframe&gt;\r\n\r\n&lt;form action=\"#\" id=\"demoForm\"&gt;\r\n    &lt;label for=\"greeting\"&gt;Enter a Greeting: &lt;\/label&gt;\r\n    &lt;input type=\"text\" name=\"greeting\" id=\"greeting\" value=\"Hello there!\" \/&gt;\r\n&lt;\/form&gt;\r\n\r\n&lt;script type=\"text\/javascript\"&gt;\r\n    var counter = 0;\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>Create a new page and add following code . <span style=\"text-decoration: underline;\"><em>parented.html<\/em><\/span><\/p>\n<pre class=\"brush:xml;highlight:[2,3]\">&lt;form action=\"#\" id=\"iframeDemoForm\"&gt;\r\n    &lt;p&gt;&lt;input name=\"button1\" type=\"button\" value=\"Click Me\" \/&gt; repeatedly to increment global variable in containing document&lt;\/p&gt;\r\n    &lt;p&gt;&lt;input name=\"button2\" type=\"button\" value=\"Click Me\" \/&gt; to transfer Greeting below to text box above&lt;\/p&gt;\r\n&lt;\/form&gt;\r\n<\/pre>\n<p>It is simpler to use the parent property to access the containing document. For example, you can reference a form in the containing document,notice line 9 of the following javascript code.<\/p>\n<p>The parent keyword can also be used to access global variables or invoke functions in the main document from the document inside the iframe, as the example below demonstrates.<\/p>\n<pre class=\"brush:js;highlight:[9,15]\">&lt;script type=\"text\/javascript\"&gt;\r\n\r\n(function() {\r\n    \/\/ get reference to form to attach button onclick handlers\r\n    var form = document.getElementById('iframeDemoForm');\r\n    \/\/ increment and display counter variable contained in parent document\r\n    form.elements['button1'].onclick = function() {\r\n        parent.counter++;\r\n        var parentCounter = 'counter in parent document is: ' + parent.counter;\r\n        this.form.elements['display'].value = parentCounter;\r\n    }\r\n\r\n    form.elements.button2.onclick = function() {\r\n        \/\/ get reference to greeting text box in containing document\r\n        var fld = parent.document.forms['demoForm'].elements['greeting'];\r\n        var val = fld.value;\r\n        \/\/ display value in iframed document's text box\r\n        this.form.elements.display.value = 'The greeting is: ' + val;\r\n    }\r\n})(); \/\/ end remove from global namespace and invoke\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>The result in the browser would be:<\/p>\n<figure id=\"attachment_11796\" aria-describedby=\"caption-attachment-11796\" style=\"width: 804px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/06\/javascriptIframeExample3.gif\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13089\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/06\/javascriptIframeExample3.gif\" alt=\"javascriptIframeExample3\" width=\"804\" height=\"398\" \/><\/a><figcaption id=\"caption-attachment-11796\" class=\"wp-caption-text\">JavaScript Interaction between Iframe and Parent<\/figcaption><\/figure>\n<h3>2.4 Dynamically Generating an Iframe<\/h3>\n<p>On this page, JavaScript is used to create an iframe element and insert it into the document. The createElement method is used to dynamically generate the iframe. Either the appendChild or insertBefore method can be used to place the iframe in the document. The setAttribute method can be used to add id, src, and other attributes.Following html and javascript demonstrates the dynamically generating of Iframe.<\/p>\n<pre class=\"brush:xml;\">       &lt;h1&gt;Dynamically Generating an Iframe&lt;\/h1&gt;\r\n       &lt;p id=\"marker\" class=\"end\"&gt;Iframes Examples&lt;\/p&gt;\r\n<\/pre>\n<pre class=\"brush:js;highlight:[3,4,8,10]\">&lt;script type=\"text\/javascript\"&gt;\r\n(function() {\r\n    var ifrm = document.createElement('iframe');\r\n    ifrm.setAttribute('id', 'ifrm');\r\n\r\n    \/\/ to place before another page element\r\n    var el = document.getElementById('marker');\r\n    el.parentNode.insertBefore(ifrm, el);\r\n\r\n    ifrm.setAttribute('src', 'http:\/\/www.webcodegeeks.com');\r\n})(); \r\n&lt;\/script&gt;\r\n<\/pre>\n<h2>3. Download the Source Code<\/h2>\n<div class=\"download\"><strong>Download: <\/strong>You can download the full source code of this example here: <a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/06\/javascript-iframe-example.zip\"><strong>Javascript Iframe Example<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The aim of this tutorial is to describe and demonstrate using JavaScript to manipulate and interact with iframes, showing how to access and modify properties of the iframe element, how to communicate with the document inside the iframe, getting information from the iframe and passing information to it. Iframes, or inline frames, allow you to &hellip;<\/p>\n","protected":false},"author":106,"featured_media":920,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-13066","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Javascript Frame Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"The aim of this tutorial is to describe and demonstrate using JavaScript to manipulate and interact with iframes, showing how to access and modify\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Javascript Frame Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"The aim of this tutorial is to describe and demonstrate using JavaScript to manipulate and interact with iframes, showing how to access and modify\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-06-08T13:15:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-10T14:30:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Saeb Najim\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Saeb Najim\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/\"},\"author\":{\"name\":\"Saeb Najim\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/7554117e1066be33eda4c81bac192cc9\"},\"headline\":\"Javascript Frame Example\",\"datePublished\":\"2016-06-08T13:15:08+00:00\",\"dateModified\":\"2018-01-10T14:30:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/\"},\"wordCount\":503,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/\",\"name\":\"Javascript Frame Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"datePublished\":\"2016-06-08T13:15:08+00:00\",\"dateModified\":\"2018-01-10T14:30:11+00:00\",\"description\":\"The aim of this tutorial is to describe and demonstrate using JavaScript to manipulate and interact with iframes, showing how to access and modify\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Javascript Frame Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/7554117e1066be33eda4c81bac192cc9\",\"name\":\"Saeb Najim\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1a6884eb32867720ef22a2a7728235120963a9a750d54d0356d5e3619ad3cd06?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1a6884eb32867720ef22a2a7728235120963a9a750d54d0356d5e3619ad3cd06?s=96&d=mm&r=g\",\"caption\":\"Saeb Najim\"},\"description\":\"Saeb has graduated from the University of Technology. During the last ten years (since 2005) he has been involved with a large number of projects about programming, software engineering, design and analysis . He works as a senior Software Engineer in the e-commerce and web development sector where he is mainly responsible for projects based on Java, Java frameworks, design patterns and Big Data technologies.\",\"sameAs\":[\"http:\/\/www.webcodegeeks.com\/\",\"https:\/\/www.linkedin.com\/in\/saebnajim\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/saeb-najim\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Javascript Frame Example - Web Code Geeks - 2026","description":"The aim of this tutorial is to describe and demonstrate using JavaScript to manipulate and interact with iframes, showing how to access and modify","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/","og_locale":"en_US","og_type":"article","og_title":"Javascript Frame Example - Web Code Geeks - 2026","og_description":"The aim of this tutorial is to describe and demonstrate using JavaScript to manipulate and interact with iframes, showing how to access and modify","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2016-06-08T13:15:08+00:00","article_modified_time":"2018-01-10T14:30:11+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","type":"image\/jpeg"}],"author":"Saeb Najim","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Saeb Najim","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/"},"author":{"name":"Saeb Najim","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/7554117e1066be33eda4c81bac192cc9"},"headline":"Javascript Frame Example","datePublished":"2016-06-08T13:15:08+00:00","dateModified":"2018-01-10T14:30:11+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/"},"wordCount":503,"commentCount":1,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/","name":"Javascript Frame Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","datePublished":"2016-06-08T13:15:08+00:00","dateModified":"2018-01-10T14:30:11+00:00","description":"The aim of this tutorial is to describe and demonstrate using JavaScript to manipulate and interact with iframes, showing how to access and modify","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-frame-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"Javascript Frame Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/7554117e1066be33eda4c81bac192cc9","name":"Saeb Najim","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1a6884eb32867720ef22a2a7728235120963a9a750d54d0356d5e3619ad3cd06?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1a6884eb32867720ef22a2a7728235120963a9a750d54d0356d5e3619ad3cd06?s=96&d=mm&r=g","caption":"Saeb Najim"},"description":"Saeb has graduated from the University of Technology. During the last ten years (since 2005) he has been involved with a large number of projects about programming, software engineering, design and analysis . He works as a senior Software Engineer in the e-commerce and web development sector where he is mainly responsible for projects based on Java, Java frameworks, design patterns and Big Data technologies.","sameAs":["http:\/\/www.webcodegeeks.com\/","https:\/\/www.linkedin.com\/in\/saebnajim"],"url":"https:\/\/www.webcodegeeks.com\/author\/saeb-najim\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/13066","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/106"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=13066"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/13066\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/920"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=13066"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=13066"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=13066"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}