浏览器调试技巧

1、前端样式 debug 专用的,浏览器执行,给所有元素加个 outline,不影响布局,给页面照个 X 光。

 1 javascript: (function () {
 2 const style = document.getElementById('outlineStyle');
 3 if (style) {
 4 style.parentNode.removeChild(style);
 5 }
 6 else {
 7 const style = document.createElement('style');
 8 style.innerText = '* {outline: 1px solid red !important}';
 9 style.id = 'outlineStyle';
10 document.head.appendChild(style);
11 }
12 })();
View Code

2、可编辑页面。

document.designMode = "on";

 

posted @ 2025-05-27 13:50  对白'  阅读(12)  评论(0)    收藏  举报