Prevent iframe Download SWF Files

2020-05-06 15:50发布

问题:

I have a swf file inside an iframe tag

<iframe width="800" height="600" frameborder="0" src="http://domain.com/swf-files/blabla.swf"></iframe>

If user doesn't have a flash player (or disabled the plugin or browser doesn't support etc.) browser tries to download this file.

This code works fine with browsers which have flash player plugin installed.

How can I prevent this file to be downloaded if flash player is not enabled? I don't care about securing the file. I just want to play the file if flash player enabled (I can do this). If flash player is not enabled, just show a message like "you don't have the plugin, you can't view this file through your browser"

回答1:

You should embed the .swf onto an html page then use the iframe to load the html.

Remember that any file extensions that aren't recognized by the browser just get downloaded, but the <embed> tag actually detects compatibility.



标签: iframe flash