{"id":9,"date":"2013-02-07T14:28:00","date_gmt":"2013-02-07T08:28:00","guid":{"rendered":"http:\/\/promincproductions.com\/blog\/?p=9"},"modified":"2014-05-03T09:11:04","modified_gmt":"2014-05-03T03:11:04","slug":"overlays-in-an-iframe","status":"publish","type":"post","link":"https:\/\/promincproductions.com\/blog\/overlays-in-an-iframe\/","title":{"rendered":"Overlays in an iFrame"},"content":{"rendered":"<p>Due to coding language issues, I recently had to iFrame my own site within my own site. &nbsp;;)<\/p>\n<p>I needed PHP to power some image generation, etc. and have this page live on a JSP page which I do not have access to the JSP code (or the knowledge of JSP). &nbsp;All I can do is drop in some HTML\/Javascript\/CSS via our CMS.<\/p>\n<p>The content within my iFramed page is a gallery of images. &nbsp;Clicking on an image would result in an overlay. &nbsp;There are several other overlays based on the actions taken on the first overlay. &nbsp;The iFrame ended up being about 4500 pixels in height. &nbsp;I was struggling to get the overlays to position correctly. &nbsp;The positioning was inconsistent across browsers, etc.<\/p>\n<p>I tried several approaches to this.<br \/>&#8211; Capturing the mouse click position and display the overlay based on that coordinate. &nbsp;I had issues with IE mainly on that one; the various versions really did not like this&#8230; &nbsp;;)<br \/>&#8211; Using a scroll to function to make the overlay always at the top and scroll the page to that point. &nbsp;Given the iFrame nature and such this just didn&#8217;t work.<\/p>\n<p>I consulted with a coworker and he steered me in the right direction. &nbsp;His suggestion was to inject the overlay into the DOM at the point of the element that was clicked and position it&nbsp;absolutely&nbsp;to that now parent&nbsp;element. &nbsp;This did the trick and works great in all browsers!<\/p>\n<p>I will admit that while I was implementing his suggestions, I realized that all of my&nbsp;overlays&nbsp;were being positioned Fixed 50px from the top. &nbsp;I&#8217;m sure that was part of the issue and maybe just changing that positioning without injecting it after the clicked image in the gallery. &nbsp;Maybe that would work, but probably not. &nbsp;And quite frankly I don&#8217;t care anymore; it&#8217;s working great! &nbsp;ha!<\/p>\n<p>Not sure if these&nbsp;ramblings&nbsp;will help anyone, but I thought it might be worth documenting.<\/p>","protected":false},"excerpt":{"rendered":"<p>Due to coding language issues, I recently had to iFrame my own site within my own site. &nbsp;;) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[13],"tags":[],"class_list":["post-9","post","type-post","status-publish","format-standard","hentry","category-php-development"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4BbcR-9","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/9","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/comments?post=9"}],"version-history":[{"count":1,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/9\/revisions"}],"predecessor-version":[{"id":43,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/9\/revisions\/43"}],"wp:attachment":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/media?parent=9"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/categories?post=9"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/tags?post=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}