小编yil*_*yin的帖子

无法在SVG g元素上应用动画

我有以下SVG文件.

        <svg
            xmlns:dc="http://purl.org/dc/elements/1.1/"
            xmlns:cc="http://creativecommons.org/ns#"
            xmlns:rdf="htntp://www.w3.org/1999/02/22-rdf-syntax-ns#"
            xmlns:svg="http://www.w3.org/2000/svg"
            xmlns="http://www.w3.org/2000/svg"
            version="1.1"
            width="1000"
            height="650"
            id="svgContainer">

            <g
                id="truck">
                <animate attributeName="fill" from="black" to="red" dur="5s"/>
                <path
                    d="m 655.589,484.36218 -6.18561,-128.61524 -110.99241,-15.79583 -34.55321,-87.58893 -94.74579,0 3.03024,178.75619 -322.238663,2.0203 0.145305,51.22351 z"
                    id="body"
                    fill="#000000"
                    stroke="#000000"
                    stroke-width="1px"
                    stroke-linecap="butt"
                    stroke-linejoin="miter"
                    stroke-opacity="1" />
                <animate attributeType="XML" attributeName="x" to="1000" begin="indefinite" dur="1s" />
                <animate attributeType="XML" attributeName="y" to="1000" begin="indefinite" dur="1s" />
            </g>
        </svg>
    </g>
</svg>
Run Code Online (Sandbox Code Playgroud)

我只想将它移动到动画的其他地方,但它不起作用.这里有什么我想念的吗?(我想g用内部的所有内容为元素设置动画.为了简单起见,我删除了其余的元素.)

html javascript svg

4
推荐指数
1
解决办法
7517
查看次数

什么是更好的DOM操作 - DOM API或innerHTML?

我有以下代码:

tr = document.createElement("tr");
root.appendChild(tr);
td = document.createElement("td");
td.appendChild(document.createTextNode("some value"));
tr.appendChild(td);
Run Code Online (Sandbox Code Playgroud)

好吧,这段代码和

root.innerHTML = "<tr><td>some value</td></tr>";
Run Code Online (Sandbox Code Playgroud)

第一个版本可能是更好的方法,因为浏览器不必呈现字符串.但它太长了.特别是对于更大的结构,这种实现变得非常难以阅读.所以我觉得有更好的方法来编写它(没有任何JavaScript库).你将如何实现这一点,以便代码更具可读性?(现在我将代码与评论分开.)

javascript dom innerhtml

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

nginx websocket反向代理配置

嗨,我正在尝试将nginx配置为websockets的反向代理.我将服务器配置如下:

server {
    listen       80;
    server_name  www.mydomain.com;

    access_log  off;
    #error_log off;

    location / {
        proxy_pass         http://127.0.0.1:8765;
        proxy_redirect     off;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $http_host;

        proxy_buffering off;
    }

}
Run Code Online (Sandbox Code Playgroud)

但是我从客户那里得到了如下错误

与'ws://www.application.com/ws'的WebSocket连接失败:WebSocket握手期间出错:'Connection'标头值不是'Upgrade'

我可能正在做一些配置错误但我看不到它.

客户端的请求标头如下

GET ws://www.talkybee.com/ws HTTP/1.1
Pragma: no-cache
Origin: http://www.talkybee.com
Host: www.talkybee.com
Sec-WebSocket-Key: Ol+O1IdaLEsHxxWRBt2oqg==
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36
Upgrade: websocket
Sec-WebSocket-Extensions: x-webkit-deflate-frame
Cache-Control: no-cache
Connection: Upgrade
Sec-WebSocket-Version: 13
Run Code Online (Sandbox Code Playgroud)

当我进行正常的直接连接时,我的连接正常.这是工作请求标题.

Cache-Control:no-cache
Connection:Upgrade
Host:www.talkybee.com:8765
Origin:http://www.talkybee.com:8765
Pragma:no-cache
Sec-WebSocket-Extensions:x-webkit-deflate-frame
Sec-WebSocket-Key:Y026b/84aUkMxVb0MaKE2A== …
Run Code Online (Sandbox Code Playgroud)

nginx websocket

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

为什么验证js字符串中的</ script>标记

我有以下页面

<html>
<head>
    <script type="text/javascript" src="e01.js"></script>
</head>
<body>
<script type="text/javascript">
var obj={someHTML: "<script>alert('a');</script>rest of the html",  
               someOtherAttribute:"some value"};
    alert(obj.someHTML);
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

在我的对象的someHTML属性中,我有</script>一个字符串中的标记.但是浏览器将其读作实际的关闭标记并关闭脚本元素.这里有什么我想念的吗?(用ff和chrome试过)

javascript

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

没有模板haskell的多形态镜头

我试图为多种类型创建一个多态镜头decleration(没有模板haskell).

module Sample where
import Control.Lens
data A = A {_value:: Int}
data B = B {_value:: Int}
data C = C {_value:: String}
value = lens _value (\i x -> i{_value=x}) -- <<< ERROR
Run Code Online (Sandbox Code Playgroud)

但我得到以下错误:

Ambiguous occurrence ‘_value’
It could refer to either the field ‘_value’,
                         defined at library/Sample.hs:5:13
                      or the field ‘_value’, defined at 
library/Sample.hs:4:13
                      or the field ‘_value’, defined at 
library/Sample.hs:3:13
  |
6 | value = lens _value (\i x -> i{_value=x}) -- <<< ERROR
  |              ^^^^^^ …
Run Code Online (Sandbox Code Playgroud)

polymorphism haskell haskell-lens

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