小编use*_*410的帖子

nodeJS - 我可以在哪里放置内容安全策略

我找到了这个CSP片段,但我不知道将它放在HTML中的哪个位置.

Content-Security-Policy: script-src 'self' https://apis.google.com
Run Code Online (Sandbox Code Playgroud)

解?

var policy = "default-src 'self'";
http.createServer(function (req, res) {
    res.writeHead(200, {
        'Content-Security-Policy': policy
    });
});
Run Code Online (Sandbox Code Playgroud)

html javascript node.js content-security-policy

8
推荐指数
1
解决办法
1万
查看次数

Java- for循环使用<<运算符

我正在研究这段代码,我不明白这行是做什么的: [(y << 3) + x]

    for (int y = 0; y <= 7; ++y) {
            for (int x = 0; x <= 7; ++x) {
                final String pieceCode = pieceCodes[(y << 3) + x];
                if (pieceCode.length() != 2) throw new IllegalArgumentException();
                if (!pieceCode.equals("--")) {
                    pieces[((7 - y) << 3) + x] = CheckersPiece.valueOf(pieceCode.charAt(0), pieceCode.charAt(1));   
                }
            }
        }
Run Code Online (Sandbox Code Playgroud)

java

3
推荐指数
1
解决办法
485
查看次数

填充base64编码更大的原因是什么?

Base 64采用3 Byte(24位)并通过4*6位表示这些.如果数据不能除以3,则额外的字节被视为一种填充?这个填充是否负责base64表示大于二进制编码?

或者为什么base64更大?

base64

2
推荐指数
1
解决办法
154
查看次数

通过JS启动CSS转换不起作用

我想开始一个CSS转换,background-color如果单击一个按钮,它会改变和维度.但是代码中有一个错误:

小提琴

jQuery的

$(function() {

$('#change').click(function() {
    $('#box').addClass('change');
});
});
Run Code Online (Sandbox Code Playgroud)

HTML

<div id="box" class="start"></div>

<div id="button">click</div>
Run Code Online (Sandbox Code Playgroud)

CSS

.start{

height:100px;
width:100px;
background: black;
transition: all 2.0s linear;
-webkit-transition: all 0.8s linear;
-moz-transition: all 0.8s linear;
-ms-transition: all 0.8s linear;
-o-transition: all 0.8s linear;
}

.change{
width: 200px;
height: 200px;
background:yellow;
}

#button{
width: 80px;
height: 20px;
padding: 4px;
margin: 5px;
border:solid 1px black;
 background: grey;
cursor: pointer;
color: white;
}
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery css3

0
推荐指数
1
解决办法
113
查看次数

如何使用url.parse(...)解析数据?

我找到了nodeJS服务器的示例代码.我不明白这行代码的作用是什么,它的真实含义是:

var urlParts = url.parse(req.url, true) 
Run Code Online (Sandbox Code Playgroud)

以下几行对我来说也不清楚.为什么写data.txt是必要的?

fs.writeFileSync("data.txt", data);
Run Code Online (Sandbox Code Playgroud)

服务器

server = http.createServer(function(req, res) {

  res.writeHead(200, {
    'Content-Type': 'text/plain',
    'Access-Control-Allow-Origin': 'http://localhost'
  });

  var urlParts = url.parse(req.url, true),
      data = urlParts.query.data;

  fs.writeFileSync("data.txt", data);

  res.end("OK");
});
Run Code Online (Sandbox Code Playgroud)

node.js

0
推荐指数
1
解决办法
1357
查看次数

标签 统计

html ×2

javascript ×2

node.js ×2

base64 ×1

content-security-policy ×1

css ×1

css3 ×1

java ×1

jquery ×1