1. 获取iframe标签属性 sandbox
默认
"" | 应用以下所有的限制。 |
allow-same-origin | 允许 iframe 内容被视为与包含文档有相同的来源。 |
allow-top-navigation | 允许 iframe 内容从包含文档导航(加载)内容。 |
allow-forms | 允许表单提交。 |
allow-scripts | 允许脚本执行。 |
JQ设置手机端和电脑端的展示
var isMobile = {
Android: function () {
return navigator.userAgent.match(/Android/i) ? true : false;
},
BlackBerry: function () {
return navigator.userAgent.match(/BlackBerry/i) ? true : false;
},
iOS: function () {
return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
},
Windows: function () {
return navigator.userAgent.match(/IEMobile/i) ? true : false;
},
any: function () {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
}
};
if (isMobile.any()) {
//如果是手机访问的话的操作!
var iframepage = document.getElementById('iframepage');
$("#iframepage").attr("sandbox", "allow-forms allow-same-origin allow-top-navigation");
} else {
var iframepage = document.getElementById('iframepage');
$("#iframepage").attr("sandbox","allow-scripts allow-forms allow-same-origin allow-top-navigation");
}