// keep_parent_background.js // RJM Programming // May, 2017 // As an HTML iframe child and parent defines document.body background, and the child has not defined background, adopt that parent one as the background function adopt_parent_background_maybe() { if (parent.document) { var fromthetop=false; // Start of more generic ideas regarding passing CSS styling ideas over via ?style=[HTMLstyleString] argument at address bar or at call to external Javascript (ie. this keep_parent_background.js) from parent var dbs = document.getElementsByTagName('body'); var pdbs = parent.document.getElementsByTagName('body'); var pdhs = parent.document.getElementsByTagName('head'); if (pdhs.length >= 1) { var passingahih = pdhs[0].innerHTML.split('keep_parent_background.js?'); if (passingahih.length <= 1) { fromthetop = true; passingahih = parent.document.URL.split('?'); } if (passingahih.length > 1) { var ph = '&' + passingahih[eval(-1 + passingahih.length)].split("'")[0].split('"')[0] + '&'; if (ph.toLowerCase().indexOf('&style=') != -1) { var sbitsare = decodeURIComponent(ph.replace('&STYLE=','&style=').replace('&sTYLE=','&style=').replace('&Style=','&style=').split('&style=')[1].split('&')[0]); var aname='',avalue='',thenpartsbits, partsbits = sbitsare.split(':'); for (var iparts=1; iparts')[0].split(' style="'); if (parent_style_bits.length > 1) { var parent_style=(";" + parent_style_bits[1].split('"')[0] + ";").replace(/ ; /g,';').replace(/; /g,';').replace(/ ;/g,';'); if (parent_style.toLowerCase().indexOf(";background") != -1) { if (dbs[0].outerHTML) { var self_style_bits=dbs[0].outerHTML.split('>')[0].split(' style="'); if (self_style_bits.length > 1) { var self_style=(";" + self_style_bits[1].split('"')[0] + ";").replace(/ ; /g,';').replace(/; /g,';').replace(/ ;/g,';'); if (self_style.toLowerCase().indexOf(";background") == -1 || 1 == 1) { if (parent_style.toLowerCase().indexOf(";background-color:") != -1) { document.body.style.backgroundColor=parent_style.toLowerCase().split(";background-color:")[1].split(";")[0].trim(); } } if (self_style.toLowerCase().indexOf("url(") == -1) { if (parent_style.toLowerCase().indexOf("url(") != -1) { var pd=parent.document; var parifs=pd.getElementsByTagName('iframe'); for (var iparifs=0; iparifs