Currently, I am facing an issue with a Pardot (Salesforce) form that is displayed within an iframe. The problem arises when the form's transparent background clashes with the parent page's background color or photo, making it difficult to read the text on the form labels. For example, if the text for "First Name" is dark on a dark background, it becomes illegible.
To address this issue, my objective is to dynamically set a body class within the iframe based on the background color of the parent element where the frame is located. This will allow the iframe to determine whether the background is light or dark and adjust the text color accordingly.
In the provided code snippet, the iframe should be able to detect whether the div.framed-lead-form has a light or dark background. While there are JavaScript plugins available to extract color information from elements (such as this one with an intriguing license: https://gist.github.com/larryfox/1636338), I haven't come across any solution that works seamlessly across iframes.
<div class="framed-lead-form">
<iframe src="//go.pardot.com/id" allowtransparency="true"></iframe>
</div>