Following up on How to rewrite URLs referenced by Javascript code? I'd like to overlay a button on top of someone else's website (e.g. overlay a Paypal button alongside Stackoverflow's bounty button) and have the two <iframe>
s scroll together. The button would reside in the top layer. The website would reside in the bottom layer.
I understand that transparent <iframe>
s were/are abused for clickjacking but the browser security mechanism seems to block legitimate use-cases. In my case the user is seeing the same button he/she is clicking. It's even possible that this is a browser bug.
Here is what I see under Chrome:
- The top
<iframe>
intercepts all mouse clicks, even for areas that do not contain any components. Meaning, users cannot interact with the bottom layer at all. - If I style the top
<iframe>
withpointer-events: none
the opposite problem occurs: users are able to see the top layer but all mouse clicks go to the bottom layer. Applyingpointer-events: auto
to child components does not help (clicks still pass through to the bottom layer). - If I size and position the top
<iframe>
so its area is equal precisely to the button I am trying to overlay, then mouse clicks go to the right layer but the top layer fails to scroll alongside the bottom layer. Meaning, the button always remains in the same absolute position as the bottom layer scrolls.
Is it possible for me to position a button in the top layer so that it always aligns with a certain position in the bottom layer? In the example where I position a Paypal button alongside the Stackoverflow bounty, I expect the Paypal button to scroll off the page as the user scrolls down the question.
https://stackoverflow.com/a/4087397/14731 leads me to believe this is not possible. Is there another way to implement this?
UPDATE: Here is a jsfiddle for you to play with. The test
button is found to the right of "NEWS & VIEWS" in the middle of the page.