【发布时间】:2018-02-15 04:48:23
【问题描述】:
我想在桌面版中显示移动版网站。 基本上我们有 2 个网站 m.xyz.com 和 xyz.com ,现在我想要通过单击预览在桌面上显示 m.xyz.com 。
<script>
$('#preview_feature').click(function() {
$('.faqModal').on('shown.bs.modal',function(){
$(this).find('iframe').attr('src','https://m.xyz.com/abc')
})
$('.faqModal').modal({show:true})
})
</script>
//On click of this button i am showing model which will preview mobile version of website
<button type="button" id="preview_feature" class="btn btn-info btn-lg btn" >Preview Feature</button>
<!-- Modal -->
<div class="modal fade faqModal" id="faqModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Preview</h4>
</div>
<div class="modal-body">
<iframe style="width:940px;height:560px;-webkit-transform:scale(1);-moz-transform-scale(1);"></iframe>
</iframe>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
【问题讨论】:
-
您的移动网站是否支持 940px 的宽度?
-
@AniruddhAgarwal 基本上问题是因为我试图在网站中预览移动网站页面。所以如果我要删除宽度或者我会给出一些其他的宽度我没关系。是否有可能在桌面上加载移动网站?
-
是的,如果您将 iframe 的宽度固定在一定程度上等于它可以显示移动网站的移动分辨率,则可以在桌面上加载移动网站。 @SumitNair
-
我尝试做同样的事情,但它仍然重定向到 www.abc.com 。我们可以更改 iframe 的用户代理吗?这样它就会打开 m.abc.com @AniruddhAgarwal
-
您可以在 abc.com 中使用 js 设置,如果窗口大小小于 500px 或其他东西,它应该重定向到 m.abc.com
标签: javascript jquery codeigniter iframe bootstrap-modal