每隔一段时间,Chrome都会错误地呈现完全有效的HTML/CSS或根本不呈现.通过DOM检查器深入挖掘通常足以让它实现其方式的错误并正确地重绘,因此可以证明标记是好的.这种情况在我正在进行的项目中经常(并且可预测地)发生,因为我已经将代码放在适当位置以在某些情况下强制重绘.
这适用于大多数浏览器/操作系统组合:
el.style.cssText += ';-webkit-transform:rotateZ(0deg)'
el.offsetHeight
el.style.cssText += ';-webkit-transform:none'
Run Code Online (Sandbox Code Playgroud)
如在,调整一些未使用的CSS属性,然后询问一些强制重绘的信息,然后取消对该属性的破坏.不幸的是,Chrome for Mac背后的聪明团队似乎找到了一种方法来获得offsetHeight而无需重绘.从而杀死了一个有用的黑客.
到目前为止,我想出的最好的方法是在Chrome/Mac上获得同样的效果:
$(el).css("border", "solid 1px transparent");
setTimeout(function()
{
$(el).css("border", "solid 0px transparent");
}, 1000);
Run Code Online (Sandbox Code Playgroud)
实际上,强制元素跳跃一点,然后冷却一秒钟然后再跳回来.更糟糕的是,如果你将超时时间降低到500毫秒以下(不太明显),它通常不会产生预期的效果,因为浏览器在返回其原始状态之前不会重新绘制.
有人愿意提供适用于Chrome/Mac的重绘/刷新黑客(最好是基于上面的第一个例子)的更好版本吗?
我有一个像这样的对象:
ricHistory = {
name1: [{
test1: value1,
test2: value2,
test3: value3
}],
name2: [{
test1: value1,
test2: value2,
test3: value3
}]
};
Run Code Online (Sandbox Code Playgroud)
现在我想用Javascript/jQuery检查例如name2是否为空.我知道这个方法hasOwnProperty
.它只适用于data.hasOwnProperty('name2')
名称是否存在,但我必须检查它是否为空.
-largeAny Ideas伙计们?我正试图在fancybox中链接打开的图像.我到处都看了!听起来很简单......
所以这是我正在使用的代码:
<a id="manual1" href="javascript:;"><img src="/example-thumb.png" alt="example" /></a>
<script type="text/javascript" src="/Cms_Data/Sites/Base/Files/js/fancyboxV2.1.0/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
$("#manual1").click(function() {
$.fancybox([
'/example-large.jpg',
'/example-large2.jpg',
{
'href' : '/example-large3.jpg',
'title' : 'Lorem ipsum '
}
], {
padding : 38,
nextEffect : 'fade',
prevEffect : 'fade'
});
});
</script>
Run Code Online (Sandbox Code Playgroud) 我有这个代码:
HTML
<table class=tbl>
<tr>
<td>
<input class='c1' type='checkbox'>
<label>Ceckbox1</label>
</td>
<td>
<input class='c2' type='checkbox'>
<label>Ceckbox2</label>
</td>
<td>
<input class='c2' type='checkbox'>
<label>Ceckbox2</label>
</td>
<td>
<input class='c2' type='checkbox'>
<label>Ceckbox2</label>
</td>
</tr>
</table>
<table class=tbl>
<tr>
<td>
<input class='c1' type='checkbox'>
<label>Ceckbox1</label>
</td>
<td>
<input class='c2' type='checkbox'>
<label>Ceckbox2</label>
</td>
<td>
<input class='c2' type='checkbox'>
<label>Ceckbox2</label>
</td>
<td>
<input class='c2' type='checkbox'>
<label>Ceckbox2</label>
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
JavaScript的
$('.c2').click(function () {
if ($(this).parent().find('.c2').is(':checked')) {
alert('all are checked');
} else {
alert('none are checked');
}
});
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用jquery仅在检查来自相同'tbl'的所有'c2'时自动检查'c1'.'c2'的计数可以变化,'tbl'的计数也可以变化.
我跟踪ruby on rails一个app点击部署.数据库做得很好,即使我检查rails控制台一切正常
017/02/26 15:34:17 [error] 18564#0: *31 connect() to unix:/var/run/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 121.52.156.57, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock:/", host: "188.166.157.124"
2017/02/26 15:35:42 [error] 32360#0: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 119.155.34.115, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock/", host: "188.166.157.124"
2017/02/26 15:42:38 [error] 6296#0: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: …
Run Code Online (Sandbox Code Playgroud) 以下是我接受创建的报价并创建答案的方法:
var description = new RTCSessionDescription(sdp),
self = this;
connection.setRemoteDescription(description, function () {
connection.createAnswer(function (answer) {
try {
connection.setLocalDescription(answer, function () {
self._mediator.sendSDPAnswer({
data: answer,
connection: connection.id
});
self._isRemoteDescriptionSet[connection.id] = true;
self._setIceCandidates(connection);
});
} catch (e) {
self._logger.error('Error while setting the remote description', e);
}
}, function (error) {
throw error;
}, {
mandatory: {
OfferToReceiveVideo: false,
OfferToReceiveAudio: true
}
});
Run Code Online (Sandbox Code Playgroud)
不幸的是,当我在Chrome中创建Firefox的报价时,我得到:
Failed to set remote offer sdp: Session error code: ERROR_CONTENT. Session error description: Failed to set data send …
Run Code Online (Sandbox Code Playgroud) 访问时间是多少:
它是O(1)像C++ 0x的unordered_map吗?
我想验证一个文本输入字段,其中输入有四个默认字符,后跟最少5个数字.
数字的最大限制没有限制.
例如:abcd123456
谁能帮助我在javascript中使用正则表达式?