简体   繁体   中英

How to stop browser open a pdf file?

I am building a website and there is an embed iframe on the page. I found that when users drop a pdf file over the iframe . The browser will close my website and load the pdf. How can I stop browser rendering the pdf file? I know the drop event I can use but this case happens in the iframe . Is there a way for me to handle drop over iframe? My iframe is loading a url which is not the same origin as the parent window.

I don't have control on the iframe I am embedded. What I want is if the iframe doesn't handle drop event then I disable the drop otherwise let iframe to handle it.

This isn't specific to an iframe, it just is what browsers do when you drag a pdf onto them - or most other files they can open, as far as I know. I wouldn't worry about it. If it's fine for every other site, it's probably fine on yours. If a user has complained, just explain it's the browser and there is nothing you can do.

People might try and find hacky ways to disable it, but my recommendation is not to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM