加载iframe中的内容具有不同的用户代理 [英] Load iframe content with different user agent

查看:745
本文介绍了加载iframe中的内容具有不同的用户代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能加载不同的用户代理的iframe?使用移动用户代理的iframe会帮助我的应用程序,以显示移动网站的悬停弹出窗口。

Is it possible to load an iframe with different user agent ?? Using a mobile user agent for an iframe will help my app to show mobile sites as hover popup.

例如,谷歌只显示如果用户代理是从移动一个移动搜索结果页。

For example, Google shows the mobile search results page only if the user agent is from a mobile one.

有没有其它的选择,或者是有参与这个想法??

Is there any alternate solutions or is there any security risks involved in this idea ??

推荐答案

您可以用JavaScript做到这一点:

You can do it with JavaScript:

navigator.__defineGetter__('userAgent', function(){
    return 'foo' // customized user agent
});

navigator.userAgent; // 'foo'

然而,这只会选择号码浏览器工作。

However, this will only work with a select number of browsers.

看到这个问题:惩戒在JavaScript的用户代理

这篇关于加载iframe中的内容具有不同的用户代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆