1.360浏览器的兼容模式坑货 2.关于ie7下display:inline-block;不支持的解决方案-

本文介绍了在360浏览器中遇到的兼容模式问题及解决方案,包括如何通过设置让浏览器以极速模式运行,以及不同域名级别下360浏览器的模式选择规律。


一:
最近在做pc官网的时候,测试拿360的浏览器测试,结果炸了,开发好久现在基本都不考虑ie的低版本了,结果测试拿的是360的ie兼容模式,跪了,css3不兼容,打开审查元素后果然和预料的一样,是ie7 的模式,而且还是标准模式哦,结果一天都在调样式,还有的接口还实现不了,马丹的。后来实在不想改了,在网上搜了下,网站用360打开的时候,给他默认的用极速模式打开,在head标签里设置。

<!-- 启用360浏览器的极速模式(webkit) -->
<meta name="renderer" content="webkit">

<!-- 启用360浏览器的极速模式(webkit) -->
<meta name="renderer" content="webkit">

忘了还有一件正事,对于好久没考虑ie6的人了。之前可是ie6 ie7都考虑的呀。这个bug忘了,今天温顾下。

如果本身是内联元素的,把它的display属性设置设置为inline-block时,所有浏览器都是支持的。
相反,如果本身是块级元素的,把它设为display:inline-block;  那么ie6/ie7都是不支持的。
IE中对内联元素使用display:inline-block,IE是不识别的,但使用display:inline-block在IE下会触发layout,从而使内联元素拥有了display:inline-block属性的表征。
这时块元素仅仅是被display:inline-block触发了layout,而它本身就是行布局,所以触发后,块元素依然还是行布局,而不会如Opera中块元素呈递为内联对象。
解决方案:
1.(这个是我这次使用的)
直接让块元素设置为内联对象呈递(设置属性display:inline),然后触发块元素的layout(如:zoom:1 或float属性等)。代码如下:
  /*推荐:IE6、7*/ div { 
                                 display:inline-block;
                                *zoom:1;
                                *display: inline;
                               }

二:下面是网上分享的一篇文章拿来借鉴下。

分享踩坑点:

项目中需要兼容360安全浏览器,大家当然都希望用极速模式打开网站,但是发现总是被兼容模式打开

网址类似 aa.xx.dd.com

 

网上找了很多地方,有以下两种方法

1.<meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1">

2.<meta name="renderer" content="webkit">

------------------------------------

第一种: ie模式按照edge(本机最高的ie版本模式)来渲染, 有chrome内核则按照chrome模式渲染

第二种:360官方提供的方法,按照为webkit模式渲染  http://bbs.360.cn/forum.php?mod=viewthread&tid=14294828&page=1#pid98784854

 

但是,都失败了。。。。。。。。

看了论坛下边的评论,有不少说<meta name="renderer" content="webkit">方法不生效的!!!!   这是坑啊,真不靠谱!!!!

 

 

然后去看了很多网站,什么百度啊,腾讯啊,都是极速模式打开的,很奇怪啊,为什么我这个是兼容模式呢?

 

然后尝试之前上线的一个项目,shit,极速模式啊,没毛病,为啥!!!

然后打开测试环境地址,瞬间我屮艸芔茻,兼容模式来了!!!!!

 

对比之后发现一个规律, 测试环境比线上地址多了一级域名,测试环境:a.b.c.com   线上: b.c.com

 

然后又去看了另一个项目,没毛病,一样的规律。

***********************************

最后,得到一个有待大家一起确认的规律:

360安全浏览器:

一级域名,使用上述第一种方式后,极速模式打开

二级域名,不管你是用啥,都是兼容模式打开

 ***************************** 更正上述对域名描述错误 | 2017-05-23 ***************************

一级(baidu.com)、二级域名(xx.baidu.com) --- 支持极速模式;

三级及以上域名(xx.xx.baidu.com)--- 不支持极速模式。

 ip直接访问 --- 不支持极速模式(来自园友评论)

 ***************************** end ***************************

 

严重怀疑,360这个研发忘了匹配多级域名的情况~~~~~~

 

 

 

*************** 补充 | 2017-07-24 *****************

补充一下关于360浏览器统计:

360安全浏览器在兼容模式下:  navigator.userAgent和原生的IE的navigator.userAgent 完全一样,意味这从ua无法分辨出是360兼容模式还是原生IE

 

360安全浏览器在极速模式下:  navigator.userAgent

 

所以,没错的话:

统计到的360安全浏览器的使用比例,应该都是极速模式下的,不包含兼容模式【兼容模式占比包含在对应版本IE的比例中】。IE占比中包含了360兼容模式的比例

 

qq浏览器,搜狗浏览器均保留了在各自浏览器标识。


<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>企业员工打卡系统</title> <!-- 引入Element Plus样式 --> <link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css"> <style> * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', Arial, sans-serif; } body { background-color: #f5f7fa; color: #333; line-height: 1.6; padding: 20px; } .container { max-width: 1000px; margin: 0 auto; padding: 20px; } header { text-align: center; margin-bottom: 30px; padding: 20px 0; border-bottom: 1px solid #ebeef5; } h1 { color: #409eff; font-size: 28px; margin-bottom: 10px; } .dashboard { display: flex; gap: 20px; margin-bottom: 30px; } .clock-card { flex: 1; background: #fff; border-radius: 8px; box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); padding: 25px; transition: all 0.3s; } .clock-card:hover { transform: translateY(-5px); box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.15); } .card-title { font-size: 18px; font-weight: 600; margin-bottom: 20px; color: #606266; display: flex; align-items: center; } .card-title i { margin-right: 8px; font-size: 20px; color: #409eff; } .input-group { margin-bottom: 20px; } .el-input { position: relative; font-size: 14px; display: inline-block; width: 100%; } .el-input__inner { -webkit-appearance: none; background-color: #fff; background-image: none; border-radius: 4px; border: 1px solid #dcdfe6; color: #606266; display: inline-block; font-size: inherit; height: 40px; line-height: 40px; outline: none; padding: 0 15px; transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1); width: 100%; } .el-input__inner:focus { border-color: #409eff; } .button-group { display: flex; gap: 12px; } .el-button { display: inline-flex; justify-content: center; align-items: center; line-height: 1; height: 40px; white-space: nowrap; cursor: pointer; background: #fff; border: 1px solid #dcdfe6; color: #606266; -webkit-appearance: none; text-align: center; box-sizing: border-box; outline: none; margin: 0; transition: .1s; font-weight: 500; padding: 12px 20px; font-size: 14px; border-radius: 4px; flex: 1; } .el-button--primary { color: #fff; background-color: #409eff; border-color: #409eff; } .el-button--primary:hover { background: #66b1ff; border-color: #66b1ff; } .el-button--success { color: #fff; background-color: #67c23a; border-color: #67c23a; } .el-button--success:hover { background: #85ce61; border-color: #85ce61; } .records-card { background: #fff; border-radius: 8px; box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); padding: 25px; } table { width: 100%; border-collapse: collapse; margin-top: 20px; } th { background-color: #fafafa; color: #909399; font-weight: 600; text-align: left; padding: 12px 15px; border-bottom: 1px solid #ebeef5; } td { padding: 12px 15px; border-bottom: 1px solid #ebeef5; color: #606266; } tr:hover td { background-color: #f5f7fa; } .el-tag { display: inline-block; height: 32px; line-height: 30px; font-size: 12px; border-radius: 4px; box-sizing: border-box; white-space: nowrap; padding: 0 10px; } .el-tag--primary { color: #409eff; background-color: #ecf5ff; border-color: #d9ecff; } .el-tag--success { color: #67c23a; background-color: #f0f9eb; border-color: #e1f3d8; } .status-indicator { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; } .status-in { background-color: #409eff; } .status-out { background-color: #67c23a; } .empty-message { text-align: center; padding: 40px 0; color: #909399; } .empty-message i { font-size: 60px; color: #c0c4cc; margin-bottom: 20px; display: block; } .clock-time { font-size: 36px; font-weight: bold; text-align: center; color: #409eff; margin: 15px 0; font-family: 'Courier New', monospace; } .date-display { text-align: center; color: #909399; margin-bottom: 20px; } .name-display { margin: 20px 0 10px; font-size: 2.2rem; font-weight: 600; letter-spacing: 2px; font-family: 'Helvetica Neue', Arial, sans-serif; } .first-name { color: #303133; position: relative; } footer { text-align: center; margin-top: 40px; color: #909399; font-size: 14px; } @media (max-width: 768px) { .dashboard { flex-direction: column; } } </style> </head> <body> <div class="container"> <header> <h1>企业员工打卡系统</h1> <div class="date-display" id="currentDate"></div> <div class="clock-time" id="currentTime"></div> </header> <div class="dashboard"> <div class="clock-card"> <div class="card-title"> <span>员工打卡</span> </div> <div class="input-group"> <div class="el-input"> <input type="text" class="el-input__inner" id="employeeName" placeholder="请输入您的姓名"> </div> </div> <!-- <div class="name-display">--> <!-- <span id="employeeName" class="first-name"></span>--> <!-- </div>--> <div class="button-group"> <button class="el-button el-button--primary" id="clockInBtn">上班打卡</button> <button class="el-button el-button--success" id="clockOutBtn">下班签退</button> </div> </div> <div class="clock-card"> <div class="card-title"> <span>今日打卡状态</span> </div> <div id="todayStatus" class="empty-message"> <div>暂无今日打卡记录</div> </div> </div> </div> <div class="records-card"> <div class="card-title"> <span>打卡记录</span> </div> <div id="recordsTable"> <table> <thead> <tr> <th>员工姓名</th> <th>打卡时间</th> <th>打卡类型</th> </tr> </thead> <tbody id="recordsBody"> <!-- 记录将通过JS动态添加 --> </tbody> </table> <div id="emptyMessage" class="empty-message"> <div>暂无打卡记录</div> </div> </div> </div> <footer> <p>企业员工打卡系统 © 2023</p> </footer> </div> <script> // 模拟API请求的URL const API_BASE_URL = 'http://localhost:8080/api/clock'; // DOM元素 const employeeNameInput = document.getElementById('employeeName'); const clockInBtn = document.getElementById('clockInBtn'); const clockOutBtn = document.getElementById('clockOutBtn'); const recordsBody = document.getElementById('recordsBody'); const emptyMessage = document.getElementById('emptyMessage'); const todayStatus = document.getElementById('todayStatus'); const currentDate = document.getElementById('currentDate'); const currentTime = document.getElementById('currentTime'); // 初始化函数 function init() { // 设置当前日期和时间 updateDateTime(); setInterval(updateDateTime, 1000); // 绑定按钮事件 clockInBtn.addEventListener('click', () => clock('IN')); clockOutBtn.addEventListener('click', () => clock('OUT')); // 获取url地址参数 const dqurl = new URL(window.location.href); const dqparams = new URLSearchParams(dqurl.search); const dquserName = dqparams.get('userName'); document.getElementById('employeeName').textContent = dquserName; // 加载打卡记录 loadRecords(); } // 更新日期和时间 function updateDateTime() { const now = new Date(); currentDate.textContent = now.toLocaleDateString('zh-CN', { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' }); currentTime.textContent = now.toLocaleTimeString('zh-CN'); } // 打卡函数 function clock(type) { // const name = employeeNameInput.value.trim(); const name = employeeNameInput.textContent; if (!name) { alert('请重新登录'); return; } // 模拟API请求 const endpoint = type === 'IN' ? 'in' : 'out'; const url = `${API_BASE_URL}/${endpoint}?name=${encodeURIComponent(name)}`; // 显示加载状态 const originalText = type === 'IN' ? clockInBtn.textContent : clockOutBtn.textContent; const button = type === 'IN' ? clockInBtn : clockOutBtn; button.textContent = '处理中...'; button.disabled = true; // 模拟API请求延迟 setTimeout(() => { // 创建打卡记录对象 const record = { id: Date.now(), employeeName: name, clockTime: new Date().toISOString(), clockType: type }; // 添加到本地存储 saveRecord(record); // 更新UI addRecordToTable(record); updateTodayStatus(); // 显示成功消息 alert(type === 'IN' ? `${name} 上班打卡成功!` : `${name} 下班签退成功!`); // 恢复按钮状态 button.textContent = originalText; button.disabled = false; // 清空输入框 employeeNameInput.value = ''; }, 800); } 保存记录到本地存储 function saveRecord(record) { const records = JSON.parse(localStorage.getItem('clockRecords') || '[]'); records.unshift(record); localStorage.setItem('clockRecords', JSON.stringify(records)); } // 从本地存储加载记录 function loadRecords() { const records = JSON.parse(localStorage.getItem('clockRecords') || '[]'); if (records.length === 0) { emptyMessage.style.display = 'block'; recordsBody.innerHTML = ''; } else { emptyMessage.style.display = 'none'; recordsBody.innerHTML = ''; records.forEach(record => { addRecordToTable(record); }); } updateTodayStatus(); } // 添加记录到表格 function addRecordToTable(record) { const row = document.createElement('tr'); // 格式化日期时间 const clockTime = new Date(record.clockTime); const formattedTime = clockTime.toLocaleString('zh-CN'); // 创建行内容 row.innerHTML = ` <td>${record.employeeName}</td> <td>${formattedTime}</td> <td> <span class="el-tag ${record.clockType === 'IN' ? 'el-tag--primary' : 'el-tag--success'}"> ${record.clockType === 'IN' ? '上班打卡' : '下班签退'} </span> </td> `; recordsBody.prepend(row); emptyMessage.style.display = 'none'; } // 更新今日打卡状态 function updateTodayStatus() { const records = JSON.parse(localStorage.getItem('clockRecords') || '[]'); const today = new Date().toDateString(); // 筛选今日记录 const todayRecords = records.filter(record => { const recordDate = new Date(record.clockTime).toDateString(); return recordDate === today; }); if (todayRecords.length === 0) { todayStatus.innerHTML = '<div>暂无今日打卡记录</div>'; return; } // 按时间排序 todayRecords.sort((a, b) => new Date(a.clockTime) - new Date(b.clockTime)); // 生成状态HTML let statusHtml = ''; todayRecords.forEach(record => { const time = new Date(record.clockTime).toLocaleTimeString('zh-CN'); statusHtml += ` <div class="status-item"> <span class="status-indicator ${record.clockType === 'IN' ? 'status-in' : 'status-out'}"></span> <span>${time} - ${record.clockType === 'IN' ? '上班打卡' : '下班签退'}</span> </div> `; }); todayStatus.innerHTML = statusHtml; } // 页面加载完成后初始化 document.addEventListener('DOMContentLoaded', init); </script> </body> </html> 将上诉的写成调用接口的方式,不存储在本地
最新发布
08-28
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值