这是一个脚本,它将html5视频的标记附加到DOM:
document.body.innerHTML = '<video id="video" controls="controls" src="http://mirror.cessen.com/blender.org/peach/trailer/trailer_iphone.m4v" type="video/mp4"></video>';
var el = document.getElementById('video');
document.body.removeChild(el);
document.body.appendChild(el);
Run Code Online (Sandbox Code Playgroud)
jsfiddle demo:http: //jsfiddle.net/h8RLS/2/
这适用于所有测试的浏览器,但iOS上的Safari除外.在iOS中,当HTMLVideoElement重新附加到DOM时,它不再可播放.
有没有其他人解决或遇到过这个问题?
当事件目标位于<img>
元素上并且缺少背景时,Internet Explorer不会触发onmousemove事件.
但它确实在目标具有背景时注册事件.有没有人对此有解释?我在IE10,IE9和IE8中有相同的行为.
在这里小提琴:http: //jsfiddle.net/xSpqE/2/
我在将页面加载到已存在的颜色框中时遇到了一些麻烦.
我点击了一个由以下代码绑定的链接打开了一个颜色框:
$("a.ajaxAddPage").colorbox({
onComplete: function(){
$('ul#addPage li a').click(function() {
$.colorbox({href: $(this).attr('href')});
return false;
});
}
});
Run Code Online (Sandbox Code Playgroud)
以下HTML通过AJAX加载到该颜色框中:
<div class='colorboxWindow'>
<ul id='addPage'>
<li><a href='addCat.php'>Add Category</a></li>
<li><a href='addPage.php' class='current'>Add New Page</a></li>
<li><a href='addPage2.php'>Add Another Page</a></li>
</ul>
<h3>Add New Page...</h3>
</div>
Run Code Online (Sandbox Code Playgroud)
我正在尝试在单击它们时在当前颜色框中打开这3个链接中的每一个.使用onComplete
上面的绑定,这适用于第一次单击,但下一次单击就像普通页面一样打开.
如果我添加其他onComplete
的$.fn.colorbox()
在上面的代码调用,那么第2点击也将加载在同一颜色框,但第3不会.
有没有办法将所有未来的点击绑定在同一个颜色框中打开?我对事件绑定还不太了解.
如果您需要澄清,请询问.
我已尝试从Web上的参考代码在页面加载时仅加载一次特定元素
这是示例代码
<script type="text/javascript">
$(document).ready(function(){
$.colorbox({width:"40%", height:"63%", inline:true, href:"#subscribe"});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
if (document.cookie.indexOf('visited=true') === -1) {
var expires = new Date();
expires.setDate(expires.getDate() 31);
document.cookie = "visited=true;
expires=" expires.toUTCString();
}
</script>
有人可以指导我,这个代码有什么问题
这是我正在编辑的html页面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8 />
<title>Popup Subscription Box</title>
<style type="text/css">
body{font:12px/1.2 Verdana, Arial, san-serrif; padding:0 10px;}
a:link, a:visited{text-decoration:none; color:#416CE5; border-bottom:1px solid #416CE5;}
h2{font-size:13px; margin:15px 0 0 0;}
</style>
<link media="screen" rel="stylesheet" href="colorbox.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<script src="../colorbox/jquery.colorbox-min.js"></script>
<script type="text/javascript">
$(document).ready(function(){ …
Run Code Online (Sandbox Code Playgroud)