{"id":44538,"date":"2019-04-10T03:01:10","date_gmt":"2019-04-09T17:01:10","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=44538"},"modified":"2019-04-08T21:13:21","modified_gmt":"2019-04-08T11:13:21","slug":"html-iframe-srcdoc-attribute-overlay-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/html-iframe-srcdoc-attribute-overlay-tutorial\/","title":{"rendered":"HTML Iframe Srcdoc Attribute Overlay Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/rain_overlay.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"HTML Iframe Srcdoc Attribute Overlay Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/rain_overlay.jpg\" title=\"HTML Iframe Srcdoc Attribute Overlay Tutorial\"  style=\"float:left;\"   \/><\/a><p class=\"wp-caption-text\">HTML Iframe Srcdoc Attribute Overlay Tutorial<\/p><\/div>\n<p>The recent <a title='HTML Iframe Srcdoc Attribute Primer Tutorial' href='#htmlisapt'>HTML Iframe Srcdoc Attribute Primer Tutorial<\/a> introduced this blog to an HTML iframe attribute new to HTML5 called &#8220;srcdoc&#8221; to be able to specify the HTML content of the page to show in the relevant HTML iframe element.  Today, like then, we are overlaying that HTML iframe content on top of the other HTML webpage content.<\/p>\n<p>Thinking back to early school, and you&#8217;ve drawn a house on a piece of paper.  What would &#8220;the younger you&#8221; (maybe) &#8220;overlay&#8221; to that drawing?   We opted for &#8220;rain&#8221;.  With that in mind we constructed a &#8220;parent&#8221; webpage consisting primarily of an image of a house as per &#8230;<\/p>\n<table style='width:100%;'>\n<tr>\n<td style='width:85%;'><img style='width:100%;' src='\/\/www.rjmprogramming.com.au\/Welcome_files\/shapeimage_1.jpg'><\/img><\/td>\n<td style='z-index:5;width:15%;text-align:center;vertical-align:top;'>\n<h1>Rain<br \/>Overlay<\/h1>\n<h3>RJM Programming &#8211; April, 2019<\/h3>\n<p>Thanks to <a target=_blank title='https:\/\/gist.github.com\/xav76\/3947289' href='https:\/\/gist.github.com\/xav76\/3947289'>https:\/\/gist.github.com\/xav76\/3947289<\/a><\/td>\n<\/tr>\n<\/table>\n<p> &#8230; then, very much thanks to <a target=_blank title='Useful rain animatikon, thanks' href='https:\/\/gist.github.com\/xav76\/3947289'>this great rain animation idea<\/a> we were able to construct a proposed &#8220;overlay&#8221; layer as per &#8230;<\/p>\n<div style=\"width:100%;height:300px;-webkit-overflow-scrolling:touch;overflow:scroll;\"><iframe style=\"width:100%;height:300px;\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/rain.html\"><\/iframe><\/div>\n<p> &#8230; and then <a target=_blank title='HTML iframe element information from w3schools' href='https:\/\/www.w3schools.com\/tags\/tag_iframe.asp'>&#8220;srcdoc&#8221;ed<\/a> them together to create <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/rain_overlay.html_GETME\" title=\"rain_overlay.html\">rain_overlay.html<\/a>&#8216;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/rain_overlay.html\" title=\"Click picture\">live run<\/a>&#8216;s look as below &#8230;<\/p>\n<div style=\"width:100%;height:400px;-webkit-overflow-scrolling:touch;overflow:scroll;\"><iframe style=\"width:100%;height:400px;\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/rain_overlay.html\"><\/iframe><\/div>\n<p> &#8230; proving that both CSS and Javascript can be in the &#8220;srcdoc&#8221; content to good effect.<\/p>\n<hr>\n<p id='htmlisapt'>Previous relevant <a target=_blank title='HTML Iframe Srcdoc Attribute Primer Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/html-iframe-srcdoc-attribute-primer-tutorial\/'>HTML Iframe Srcdoc Attribute Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/iframe_srcdoc.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"HTML Iframe Srcdoc Attribute Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/iframe_srcdoc.jpg\" title=\"HTML Iframe Srcdoc Attribute Primer Tutorial\"  style=\"float:left;\"   \/><\/a><p class=\"wp-caption-text\">HTML Iframe Srcdoc Attribute Primer Tutorial<\/p><\/div>\n<p>The HTML iframe element is a great element allowing inline new webpage content.  This is controlled, traditionally, via the attribute (and thanks to <a target=_blank title='HTML iframe element information from w3schools' href='https:\/\/www.w3schools.com\/tags\/tag_iframe.asp'>W3Schools<\/a> for the heads up here) &#8230;<\/p>\n<table>\n<tr>\n<th>Attribute<\/th>\n<th>Value<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td>src<\/td>\n<td>URL<\/td>\n<td>Specifies the address of the document to embed in the &lt;iframe&gt;<\/td>\n<\/tr>\n<\/table>\n<p> &#8230; but, as of HTML5, a new HTML iframe attribute was introduced as below &#8230;<\/p>\n<table>\n<tr>\n<th>Attribute<\/th>\n<th>Value<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td>srcdoc<\/td>\n<td>HTML code<\/td>\n<td>Specifies the HTML content of the page to show in the &lt;iframe&gt;<\/td>\n<\/tr>\n<\/table>\n<p> &#8230; featuring functionality I&#8217;ve often wanted over a long period of time.<\/p>\n<p>Today we create a &#8220;proof of concept&#8221; web application which puts this HTML iframe &#8220;srcdoc&#8221; attribute through its paces by overlaying, using our (2 out of 3, minus &#8220;opacity&#8221;) usual &#8220;overlay suspects&#8221; &#8230;<\/p>\n<ul>\n<li><a target=_blank title='CSS position:absolute information from w3schools' href='http:\/\/www.w3schools.com\/cssref\/pr_class_position.asp'>position:absolute<\/a> property<\/li>\n<li><a target=_blank title='CSS z-index information from w3schools' href='http:\/\/www.w3schools.com\/cssref\/pr_pos_z-index.asp'>z-index<\/a><\/li>\n<\/ul>\n<p> &#8230; to &#8220;slap&#8221; entire HTML iframe element contents over the top of existent content, specifying that HTML content via this &#8220;srcdoc&#8221; attribute.<\/p>\n<p>You can try this for yourself in a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/iframe_srcdoc.html\" title=\"Click picture\">new window<\/a> with this, or see <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/iframe_srcdoc.html_GETME\">iframe_srcdoc.html<\/a> in action, in a blog posting HTML iframe, below &#8230;<\/p>\n<p><iframe style='width:100%;height:300px;' src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/iframe_srcdoc.html'><\/iframe><\/p>\n<p> &#8230; or, perhaps, see what we mean in terms of seeing it <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/iframe_srcdoc.mov\" title=\"Video\">&#8220;play out&#8221;<\/a> with the Google Chrome web browser and its Developer Tools &#8220;Web Inspector&#8221; tool, below.<\/p>\n<p><video style=\"width:100%;height:370px;\" controls><source src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/iframe_srcdoc.mov' type='video\/mp4'><\/source><\/video><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d44479' onclick='var dv=document.getElementById(\"d44479\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/iframe\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d44479' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d44538' onclick='var dv=document.getElementById(\"d44538\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/overlay\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d44538' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The recent HTML Iframe Srcdoc Attribute Primer Tutorial introduced this blog to an HTML iframe attribute new to HTML5 called &#8220;srcdoc&#8221; to be able to specify the HTML content of the page to show in the relevant HTML iframe element. &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/html-iframe-srcdoc-attribute-overlay-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2824,84,257,576,578,587,652,894,997,2906,2506,2902,1319,1496],"class_list":["post-44538","post","type-post","status-publish","format-standard","hentry","category-uncategorised","tag-absolute","tag-animation-2","tag-content","tag-html","tag-html5","tag-iframe","tag-javascript","tag-overlay","tag-programming","tag-rain","tag-src","tag-srcdoc","tag-tutorial","tag-z-index"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/44538"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=44538"}],"version-history":[{"count":3,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/44538\/revisions"}],"predecessor-version":[{"id":44583,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/44538\/revisions\/44583"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=44538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=44538"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=44538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}