Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page jumps to top when iframe is clicked

Tags:

iframe

My page jumps to the top when I embed this gdrive iframe, once you click on the iframe:

<iframe height="400px" frameborder="0" width="600px" src="https://docs.google.com/document/d/1u9NFjTPBd-9mucQUPvkqLP84iV6uaEcJNF5vQdHmYh8/edit?usp=sharing&rm=embedded"></iframe>

JSFiddle: https://jsfiddle.net/0qpe53os/

Question: Why does it do so and how can I prevent it from doing so?

I tried to preventDefault without any luck. Thanks a lot in advance for your help.

like image 640
bersling Avatar asked Jan 06 '16 08:01

bersling


1 Answers

I'm not sure if this is useful. By the way you could use the onload attribute to scroll the page down: onload="scroll(0,screen.height);"

<iframe height="400px" frameborder="0" width="600px" src="https://docs.google.com/document/d/1u9NFjTPBd-9mucQUPvkqLP84iV6uaEcJNF5vQdHmYh8/edit?usp=sharing&rm=embedded"  onload="scroll(0,screen.height);"></iframe>
like image 128
Cafaro Rosario Avatar answered Nov 15 '22 00:11

Cafaro Rosario