{"id":55864,"date":"2022-05-23T03:01:22","date_gmt":"2022-05-22T17:01:22","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=55864"},"modified":"2022-05-21T12:08:07","modified_gmt":"2022-05-21T02:08:07","slug":"clone-within-clone-ajax-html-iframe-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/clone-within-clone-ajax-html-iframe-tutorial\/","title":{"rendered":"Clone Within Clone Ajax HTML Iframe Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/ajax_html.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Clone Within Clone Ajax HTML Iframe Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/ajax_html.jpg\" title=\"Clone Within Clone Ajax HTML Iframe Tutorial\"  style=\"float:left;\"   \/><\/a><p class=\"wp-caption-text\">Clone Within Clone Ajax HTML Iframe Tutorial<\/p><\/div>\n<p>Can Ajax return you HTML data, if you are okay with an asynchronous call?<\/p>\n<blockquote><p>\nGlad you asked.  Yes.\n<\/p><\/blockquote>\n<p>And just such an idea features in our <i>Clone Within Clone<\/i> idea we want to show you as a proof of concept today.<\/p>\n<p>With this <i>Clone Within Clone<\/i> idea we use an HTML iframe <a target=_blank title='Iframe srcdoc attribute information from W3schools' href='https:\/\/www.w3schools.com\/tags\/att_iframe_srcdoc.asp#:~:text=The%20srcdoc%20attribute%20specifies%20the,src%20attribute%20(if%20present).'>srcdoc<\/a> attribute as the conduit to cloning a webpage HTML into an embedded iframe.  And then we offer the user the nine second chance to keep the embedding going by clicking a link in time, to set up a hierarchy of one webpage as the top hierarchy for a hierarchy series of embedded iframe elements.<\/p>\n<p>The <a target=_blank title='Ajax information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Ajax_(programming)'>Ajax<\/a> Javascript code which results in HTML output <font color=blue>is shown below<\/font> helping <font color=purple>populate the relevant HTML iframe srcdoc attribute<\/font> &#8230;<\/p>\n<p><code><br \/>\n<font color=blue>var zhr=null;<br \/>\nvar zform=null;<br \/>\nvar rawhtml='';<\/font><br \/>\nvar calling=location.search.split('calling=')[1] ? decodeURIComponent(location.search.split('calling=')[1].split('&')[0]) : '' + ('' + document.referrer).replace('undefined','');<br \/>\nvar qclick=false;<br \/>\nvar countdown=9;<br \/>\nvar lh=location.search.split('calling=')[1] ? decodeURIComponent(location.search.split('calling=')[1].split('&')[0]) : '0';<br \/>\nlh='' + eval(1 + eval('' + lh));<br \/>\nif (calling.indexOf('rjmprogramming.com.au\/ITblog\/clone-within-clone-ajax-html-iframe-tutorial') != -1 && eval('' + lh) == 1) { calling=''; }<br \/>\nif (eval('' + lh) > 1 && calling == '') { calling=' '; }<br \/>\n<br \/>\n<font color=blue>function stateChanged() {<br \/>\n if (zhr.readyState == 4) {<br \/>\n  if (zhr.status == 200) {<br \/>\n   rawhtml = zhr.response;<\/font><br \/>\n   if (calling == '' || qclick) {<br \/>\n     document.getElementById('myif').style.display='block';<br \/>\n     <font color=purple>if (rawhtml.indexOf('&lt;span id=\"spancq\"&gt;clicked&lt;\/span&gt;') != -1 && rawhtml.indexOf('&gt;&lt;\/a&gt;') != -1) {<br \/>\n     document.getElementById('myif').srcdoc=rawhtml.replace(\" : '0';\", \" : '\" + lh + \"';\").replace('&lt;span id=\"spancq\"&gt;clicked&lt;\/span&gt;', '&lt;span id=\"spancq\"&gt;&lt;\/span&gt;').replace('&gt;&lt;\/a&gt;', '&gt;click here&lt;\/a&gt;');<br \/>\n     } else {<br \/>\n     document.getElementById('myif').srcdoc=rawhtml.replace(\" : '0';\", \" : '\" + lh + \"';\");<br \/>\n     }<\/font><br \/>\n     if (calling != '') {<br \/>\n       var sofarhh=eval(('' + parent.document.getElementById('myif').style.height).replace('px',''));<br \/>\n       console.log('sofarhh=' + sofarhh);<br \/>\n       parent.document.getElementById('myif').style.height='' + eval(sofarhh + eval(50 + eval('' + document.getElementsByTagName('div')[0].getBoundingClientRect().height))) + 'px';<br \/>\n       parent.document.getElementById('myspan').innerHTML='' + lh;<br \/>\n     }<br \/>\n   }<br \/>\n  <font color=blue>}<br \/>\n }<br \/>\n}<\/font><br \/>\n<br \/>\nfunction ajaxit() {<br \/>\n  document.getElementById('acq').innerHTML='';<br \/>\n  document.getElementById('acq').style.cursor='pointer';<br \/>\n  document.getElementById('spancq').innerHTML='clicked';<br \/>\n  countdown=0;<br \/>\n  document.getElementById('more').innerHTML='';<br \/>\n  document.getElementById('myif').style.width='' + eval(16 + eval('' + document.getElementsByTagName('h1')[0].getBoundingClientRect().width)) + 'px';<br \/>\n  document.getElementById('myif').style.height='' + eval(50 + eval('' + document.getElementsByTagName('div')[0].getBoundingClientRect().height)) + 'px';<br \/>\n  <font color=blue>zhr = new XMLHttpRequest();<br \/>\n  zform = new FormData();<\/font><br \/>\n  document.getElementById('myh1').title='This Child level ' + lh;<br \/>\n  console.log('Child level ' + lh);<br \/>\n  <font color=blue>zform.append('calling', '' + lh);<br \/>\n  zhr.responseType='Document';<br \/>\n  zhr.onreadystatechange=stateChanged;<br \/>\n  zhr.open('get', '.\/ajax_html.html', true);<br \/>\n  zhr.send(zform);<\/font><br \/>\n}<br \/>\n<\/code><\/p>\n<p> &#8230; appearing in <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/ajax_html.html_GETME\" title=\"ajax_html.html\">ajax_html.html<\/a>&#8216;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/ajax_html.html\" title=\"Click picture\">web application<\/a> you can also try below (or <a onclick=\"document.getElementById('cloneif').src='\/\/www.rjmprogramming.com.au\/HTMLCSS\/ajax_html.html?random=' + Math.floor(Math.random() * 198765453);\" style=\"text-decoration:underline;cursor:pointer;\">click here<\/a> if it is sitting there looking at you like a wet lettuce) &#8230;<\/p>\n<p><iframe id=cloneif src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/ajax_html.html?rand=675476\" style=\"width:100%;height:1200px;\"><\/iframe><\/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='#d55864' onclick='var dv=document.getElementById(\"d55864\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/srcdoc\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d55864' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Can Ajax return you HTML data, if you are okay with an asynchronous call? Glad you asked. Yes. And just such an idea features in our Clone Within Clone idea we want to show you as a proof of concept &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/clone-within-clone-ajax-html-iframe-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":[2,12,14,37],"tags":[69,1549,576,587,652,2018,997,2124,2902,1319],"class_list":["post-55864","post","type-post","status-publish","format-standard","hentry","category-ajax","category-elearning","category-event-driven-programming","category-tutorials","tag-ajax","tag-element","tag-html","tag-iframe","tag-javascript","tag-onstatechanged","tag-programming","tag-response","tag-srcdoc","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/55864"}],"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=55864"}],"version-history":[{"count":11,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/55864\/revisions"}],"predecessor-version":[{"id":55875,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/55864\/revisions\/55875"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=55864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=55864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=55864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}