我坚持使用这个javascript代码;它没有执行超时!! 即使我点击任何链接,它也不能正常工作。 我正在使用chrome:版本34.0.1847.116 Ubuntu 12.04
任何人都可以帮助我!!!
这些是我正在使用的漏洞代码 我的jquery版本是1.11.1。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html data-wf-site="53314860dc25c5ac0a0001b9">
<head>
<meta charset="utf-8">
<title>Tactutalities - Administration</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="generator" content="Webflow">
<!-- CSS Librairy -->
<link rel="stylesheet" type="text/css" href="/public/css/normalize.css">
<link rel="stylesheet" type="text/css" href="/public/css/webflow.css">
<link rel="stylesheet" type="text/css" href="/public/css/tactualities.webflow.css">
<link rel="stylesheet" href="/public/css/semantic.min.css" type="text/css" media="screen, projection" />
<link rel="stylesheet" type="text/css" href="/public/css/map.css">
<link rel="stylesheet" type="text/css" href="/public/css/MarkerCluster.css" />
<link rel="stylesheet" type="text/css" href="/public/css/MarkerCluster.Default.css" />
<link rel="stylesheet" type="text/css" href="/public/css/Control.Loading.css" />
<link rel="stylesheet" type="text/css" href="/public/css/L.Control.Sidebar.css" />
<link rel="stylesheet" type="text/css" href="/public/css/leaflet.fusesearch.css" />
<link rel="stylesheet" type="text/css" href="/public/css/pace/pace.css" />
<link rel="stylesheet" type="text/css" href="/public/css/leaflet.css" />
<link rel="stylesheet" type="text/css" href="/public/css/Control.MiniMap.css" />
<link rel="stylesheet" type="text/css" href="/public/css/jqueryui.css">
<link rel="stylesheet" type="text/css" href="/public/css/l.geosearch.css"/>
<link rel="shortcut icon" type="image/x-icon" href="https://y7v4p6k4.ssl.hwcdn.net/placeholder/favicon.ico">
<!-- jQuery Librairy -->
<script type="text/javascript" src="/public/js/jquery.js"></script>
<script type="text/javascript" src="/public/js/jqueryui.js"></script>
<!-- Application JS Librairy -->
<script type="text/javascript" src="/public/js/prototype.js"></script>
<script type="text/javascript" src="/public/js/effects.js"></script>
<script type="text/javascript" src="/public/js/application.js"></script>
<script type="text/javascript" src="/public/js/validation.js"></script>
<script type="text/javascript" src="/public/js/ajaxRequest.js"></script>
<script type="text/javascript" src="/public/js/webfont.js"></script>
<script type="text/javascript" src="/public/js/tools.js"></script>
<!-- Map JS Librairy -->
<script type='text/javascript' src="/public/js/map/leaflet.js"></script>
<script type="text/javascript" src="/public/js/map/fuse.js"></script>
<script type="text/javascript" src="/public/js/map/leaflet.fusesearch.js"></script>
<script type='text/javascript' src='/public/js/map/pace.js'></script>
<script type='text/javascript' src='/public/js/map/countries.geo.json'></script>
<script type='text/javascript' src="/public/js/map/leaflet.markercluster-src.js"></script>
<script type='text/javascript' src="/public/js/map/Control.FullScreen.js"></script>
<script type="text/javascript" src="/public/js/map/L.Control.Sidebar.js"></script>
<script type="text/javascript" src="/public/js/map/Control.MiniMap.js"></script>
<script type="text/javascript" src="/public/js/map/geoSearch/l.control.geosearch.js"></script>
<script type="text/javascript" src="/public/js/map/geoSearch/l.geosearch.provider.google.js"></script>
<script type="text/javascript">
var j = jQuery.noConflict();
/**
* disable double click
**/
console=console || {};
console.log=console.log || {};
jQuery(document).ready(function() {
jQuery(document).on('click', function(event) {
var target = event.target;
if (target.tagName==='A' || target.tagName==='IMG' || target.tagName==='BUTTON' ) {
if ( jQuery(target).data("clicked") ) {
console.log('Target',target.tagName,' Already Clicked');
event.stopPropagation();
event.preventDefault();
console.log("double click event disabled");
return false;
} else {
console.log('Target',target.tagName,' not Clicked yet');
jQuery(target).data("clicked", true);
jQuery(target).prop('disabled', true);
jQuery(target).addClass("clicked");
setTimeout(function()
{
jQuery(target).data("clicked", false);
jQuery(target).prop('disabled', false);
jQuery(target).removeClass("clicked");
console.log('You can click Again!');
}, 5000); // Do something after 5000 millisecondes
return true;
}
} else {
console.log('Target ',target.tagName,' will not trigger any actions');
}
});
});
</script>
</head>
答案 0 :(得分:0)
我将部分脚本改写为
/**
* disable double click
**/
console=console || {};
console.log=console.log || {};
jQuery(document).ready(function() {
jQuery(document).on('click', function(event) {
var targetElement = event.target || event.srcElement;
var target = jQuery(targetElement);
if (targetElement.tagName==='A' || targetElement.tagName==='IMG' || targetElement.tagName==='BUTTON' ) {
if ( target.data("clicked") )
{
console.log('Target',targetElement.tagName,' already Clicked');
event.stopPropagation();
event.preventDefault();
console.log("double click event disabled");
return false;
} else {
console.log('Target',targetElement.tagName,' not Clicked yet. We will disable it now');
target.data("clicked", true);
target.prop('disabled', true);
target.addClass("clicked");
setTimeout(function()
{
target.data("clicked", false);
target.prop('disabled', false);
target.removeClass("clicked");
console.log("ok, you can click again");
}, 5000); // Do something after 5000 millisecondes
return true;
}
} else {
console.log('Target was a ',targetElement.tagName,' will not trigger any actions');
}
});
});
请在行动中看到它