早些时候,当我使用 Firebug 并打开新选项卡时 - Firebug 已在那里激活。现在,在 Firefox 51.0.1 中,我需要F12每次按一次才能打开 Firefox DevTools。如何在新标签页中默认激活它们?
about:config中的allPagesActivation选项没有帮助。
如果颜色是数字,那么我们可以使用正则表达式来检查颜色是否是有效的css颜色.但言语怎么样?
我有一个动态生成控件并获取颜色的代码.但不是颜色,可能有"空",""或随机的单词.有没有办法用javascript检查颜色名称?
更新:非常感谢您的回答!:)我的最终版本是(添加到较低的检查,因为可能有"绿色","红色"等):
function isValidColor(strColor) {
var s = new Option().style;
s.color = strColor;
// return 'false' if color wasn't assigned
return s.color == strColor.toLowerCase();
}
Run Code Online (Sandbox Code Playgroud) 我有 index.html 文件,其中包含 ' Hello world! ' h1 中的文本:
<!DOCTYPE HTML>
<html>
<head>
<title></title>
<meta charset="UTF-8">
</head>
<body>
<h1>Hello world!</h1>
<script src="bundle.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我的 index.test.js:
import {expect} from 'chai';
import jsdom from 'jsdom';
import fs from 'fs';
describe('index.html', () => {
it("should say 'Hello world!'", () => {
// read file content to variable
const index = fs.readFileSync('./src/index.html', "utf-8");
// pass this variable to jsdom:
jsdom.env(index, function(err, window) {
const h1 = window.document.getElementByTagName('h1')[0]; // read our h1
expect(h1.innerHTML).to.equal("Helloooooooo World!"); …Run Code Online (Sandbox Code Playgroud)