function loadpage(url) { initializeobjects(); document.getElementById('pixelsiframe').src = url; showpixelsiframe(); } function resizemainiframe(height) { if(true && document.getElementById('pixelsshoppingcartiframe')) { document.getElementById('pixelsshoppingcartiframe').style.height = (height + 0) + 'px'; } else { // This is for users who added the iframe to their websites before the iframe has id='pixelsshoppingcartiframe'. var documentiframes = document.getElementsByTagName('iframe'); var currentsrc = ''; for(var i = 0; i < documentiframes.length; i ++) { currentsrc = documentiframes[i].src; if(currentsrc.indexOf('widgetshoppingcart/artwork') > 0) { documentiframes[i].style.height = (height + 0) + 'px'; } } } } function scrollmainiframe() { if(document.getElementById('pixelsshoppingcartiframe')) { document.getElementById('pixelsshoppingcartiframe').scrollIntoView(true); } else { // This is for users who added the iframe to their websites before the iframe has id='pixelsshoppingcartiframe'. var documentiframes = document.getElementsByTagName('iframe'); var currentsrc = ''; for(var i = 0; i < documentiframes.length; i ++) { currentsrc = documentiframes[i].src; if(currentsrc.indexOf('widgetshoppingcart/artwork') > 0) { documentiframes[i].scrollIntoView(true); } } } } function centerpixelsiframe() { var widthclient = parseInt(document.documentElement.clientWidth); var heightclient = parseInt(document.documentElement.clientHeight); if(true && window.innerHeight) { if(parseInt(window.innerHeight) != 0 && parseInt(window.innerHeight) < heightclient) { heightclient = parseInt(window.innerHeight); } } var widthtarget = parseInt(widthclient*0.95); var heighttarget = parseInt(heightclient*0.95); if(widthclient < 400) { widthtarget = parseInt(widthclient); heighttarget = parseInt(heightclient); } var offsetx = 0; var offsety = 0; if(document.getElementById('pixelsiframeparentdiv')) { var targetobject = document.getElementById('pixelsiframeparentdiv'); targetobject.style.width = widthtarget + 'px'; targetobject.style.height = heighttarget + 'px'; targetobject.style.left = (offsetx + parseInt((widthclient - widthtarget) / 2)) + 'px'; targetobject.style.top = (offsety + parseInt((heightclient - heighttarget) / 2)) + 'px'; } } function showpixelsiframe() { centerpixelsiframe(); var backgroundobject = document.getElementById('backgrounddiv'); var targetobject = document.getElementById('pixelsiframeparentdiv'); backgroundobject.style.width = '100%'; backgroundobject.style.height = '100%'; backgroundobject.style.visibility = 'visible'; targetobject.style.visibility = 'visible'; } function hidepixelsiframe() { document.getElementById('backgrounddiv').style.visibility = 'hidden'; document.getElementById('pixelsiframeparentdiv').style.visibility = 'hidden'; document.getElementById('pixelsiframe').src = 'https://fineartamerica.com/widgetshoppingcart/loading.php'; } function initializeobjects() { var newparentdiv; var newdiv; var cssstyle; if(!document.getElementById('backgrounddiv')) { newdiv = document.createElement('div'); cssstyle = 'position: fixed; z-index: 1000; left: 0px; top: 0px; width: 10px; height: 10px; background-color: #000000; visibility: hidden; opacity: 0.65; filter: alpha(opacity=50);'; newdiv.id = 'backgrounddiv'; newdiv.setAttribute('style',cssstyle); newdiv.style.cssText = cssstyle; document.body.appendChild(newdiv); } if(!document.getElementById('pixelsiframeparentdiv')) { newparentdiv = document.createElement('div'); cssstyle = 'position: fixed; z-index: 100000; width: 10px; height: 10px; background-color: #FFFFFF; border: 1px solid #444444; box-shadow: 0px 0px 40px #000000; visibility: hidden;'; newparentdiv.id = 'pixelsiframeparentdiv'; newparentdiv.setAttribute('style',cssstyle); newparentdiv.style.cssText = cssstyle; newdiv = document.createElement('iframe'); cssstyle = 'width: 100%; height: 100%; border: none;'; newdiv.id = 'pixelsiframe'; newdiv.src = 'https://fineartamerica.com/widgetshoppingcart/loading.php'; newdiv.setAttribute('style',cssstyle); newdiv.style.cssText = cssstyle; var useragent = window.navigator.userAgent; if(useragent.match(/iPad/i) || useragent.match(/iPhone/i)) { // iPad or iPhone newparentdiv.style.overflowY = 'scroll'; newparentdiv.style.webkitOverflowScrolling = 'touch'; } else { // Anything else } document.body.appendChild(newparentdiv); document.getElementById('pixelsiframeparentdiv').appendChild(newdiv); } } window.addEventListener('orientationchange',centerpixelsiframe); window.addEventListener('resize',centerpixelsiframe); // http://davidwalsh.name/window-iframe // http://stackoverflow.com/questions/3800309/using-postmessage-to-refresh-iframes-parent-document // Create IE + others compatible event handler var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent"; var eventer = window[eventMethod]; var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message"; // Listen to message from child window eventer(messageEvent,function(e) {eval(e.data)},false);