所以我在网站上有一个部分,我在iframe中显示pdf。这在电脑上运行得非常好。然而,一些移动设备在加载网站时会立即开始下载pdf。
这是我使用的代码。
<div class="showbox" style="display: none;">
<div class="embed-container">
<iframe src="/images/pdf-file.pdf" style="border:none;"></iframe>
</div>
</div>
所以我只希望移动用户能够访问网站,而无需自动下载pdf
有什么办法吗?
使用Responsive实用程序类怎么样?
看看:http://getbootstrap.com/2.3.2/scaffolding.html#responsive
向下滚动,直到"Responsive utility classes"
您可以这样设置html:
<div class="showbox" style="display: none;">
<div class="embed-container">
</div>
</div>
然后把这个js放在任何地方:
if( !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
$('.showbox .embed-container').append('<iframe src="/images/pdf-file.pdf" style="border:none;"></iframe>');
}