mirror of
https://github.com/AEPKILL/devtools-detector.git
synced 2026-04-26 23:15:48 +03:00
[GH-ISSUE #6] Mac FireFox上的表现有点问题 #4
Labels
No labels
bug
bug
enhancement
help wanted
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/devtools-detector#4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @JnathanCoder on GitHub (Jun 27, 2019).
Original GitHub issue: https://github.com/AEPKILL/devtools-detector/issues/6
@AEPKILL commented on GitHub (Jun 30, 2019):
检测控制台是否打开的的原理是在浏览器中执行
console.log时,打开控制台和关闭控制台的行为略有差异。但是在火狐浏览器下打开控制台但是不切换到
Console面板下的时候,console.log输出的内容并不会真正的被输出。所以常规的常规的
console.log的做法在Firefox打开控制台但没有切换到Console面板下的时候 就失效了为了规避这种情况,判断控制台是否打开又增加了这样一段逻辑:
这段逻辑不会即时反应控制台的打开状态,但是会在关闭控制台的瞬间显示曾经打开过控制台,而且会影响他人做代码调试,所以我把它作为替代方案,也就出现了你描述的情况。
如果有更优雅的方法,Pull request welcome.
@JnathanCoder commented on GitHub (Jul 2, 2019):
好的 感谢回复。------------------ 原始邮件 ------------------
发件人: "AEPKILL"notifications@github.com
发送时间: 2019年6月30日(星期天) 中午11:35
收件人: "AEPKILL/devtools-detector"devtools-detector@noreply.github.com;
抄送: "JnathanCoder"949204575@qq.com;"Author"author@noreply.github.com;
主题: Re: [AEPKILL/devtools-detector] Mac FireFox上的表现有点问题 (#6)
检测控制台是否打开的的原理是在浏览器中执行 console.log 时,打开控制台和关闭控制台的行为略有差异。
但是在火狐浏览器下打开控制台但是不切换到 Console 面板下的时候,console.log 输出的内容并不会真正的被输出。
所以常规的常规的 console.log 的做法在 Firefox 打开控制台但没有切换到 Console 面板下的时候 就失效了
为了规避这种情况,判断控制台是否打开又增加了这样一段逻辑:
const start = performance.now(); debugger; const isOpen = now() - startTime > 100;
这段逻辑不会即时反应控制台的打开状态,但是会在关闭控制台的瞬间显示曾经打开过控制台,而且会影响他人做代码调试,所以我把它作为替代方案,也就出现了你描述的情况。
如果有更优雅的方法,Pull request welcome.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.