如何在事件时间结束后与下面的每个计时器调用URL ?我通过了所有的倒计时代码。我需要找到我在哪里放置URL,这将是超链接图像后计时器显示,时间结束后的图片显示,但与未定义的URL链接。这里我声明这个variable = +match_link+
来显示事件后的链接:
var match_link = digits[elem].parent().parent().parent().children('.match-info').children('a:first-child').attr('href');
digits[elem].parent().parent().html('<a href="'+match_link+'" class="live-now"><img width="145" height="35" src="http://files.barcelonastream.com/media-resources/other/WatchNow.png" class="attachment-medium" alt="WatchNow" title="WatchNow"></a>');
<html>
<head>
<script type="text/javascript">
//<![CDATA[
try{if (!window.CloudFlare) {var CloudFlare=[{verbose:0,p:0,byc:0,owlid:"cf",bag2:1,mirage2:0,oracle:0,paths:{cloudflare:"/cdn-cgi/nexp/dok3v=1613a3a185/"},atok:"cc11de0e81b190b819ea8d9a1ae30b94",petok:"bebab39309d8af2d0876cf8ed34772ef3629ea6f-1443543175-1800",zone:"realmadridlive.in",rocket:"a",apps:{}}];document.write('<script type="text/javascript" src="//ajax.cloudflare.com/cdn-cgi/nexp/dok3v=e9627cd26a/cloudflare.min.js"><'+'/script>');}}catch(e){};
//]]>
</script>
<script type="text/rocketscript" data-rocketsrc="http://realmadridlive.in/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
jQuery.fn.countdown = function(userOptions)
{
// Default options
var options = {
stepTime: 60,
// startTime and format MUST follow the same format.
// also you cannot specify a format unordered (e.g. hh:ss:mm is wrong)
format: "dd:hh:mm:ss",
eventTime: "Jan, 1, 2014, 00:00",
digitImages: 6,
digitWidth: 53,
digitHeight: 77,
timerEnd: function(){},
image: "digits.png"
};
var digits = [], interval;
userOptions.startTime = timeleft(userOptions.eventTime);
// Draw digits in given container
var createDigits = function(where)
{
var c = 0;
var tempStartTime = options.startTime;
// Iterate each startTime digit, if it is not a digit
// we'll asume that it's a separator
for (var i = 0; i < options.startTime.length; i++)
{
if (parseInt(tempStartTime.charAt(i)) >= 0)
{
elem = jQuery('<div id="cnt_' + i + '" class="cntDigit" />').css({
height: options.digitHeight * options.digitImages * 10,
float: 'left', background: 'url('' + options.image + '')',
width: options.digitWidth});
digits.push(elem);
margin(c, -((parseInt(tempStartTime.charAt(i)) * options.digitHeight *
options.digitImages)));
digits[c].__max = 9;
// Add max digits, for example, first digit of minutes (mm) has
// a max of 5. Conditional max is used when the left digit has reach
// the max. For example second "hours" digit has a conditional max of 3
switch (options.format.charAt(i)) {
case 'h':
digits[c].__max = (c % 2 == 0) ? 2: 9;
if (c % 2 != 0)
digits[c].__condmax = 3;
break;
case 'd':
digits[c].__max = 9;
break;
case 'm':
case 's':
digits[c].__max = (c % 2 == 0) ? 5: 9;
}
++c;
}
else
elem = jQuery('<div class="cntSeparator"/>').css({float: 'left'})
.text(tempStartTime.charAt(i));
where.append('<div>');
where.append(elem);
where.append('</div>');
}
};
// Set or get element margin
var margin = function(elem, val)
{
if (val !== undefined)
return digits[elem].css({'marginTop': val + 'px'});
return parseInt(digits[elem].css('marginTop').replace('px', ''));
};
// Makes the movement. This is done by "digitImages" steps.
var moveStep = function(elem)
{
digits[elem]._digitInitial = -(digits[elem].__max * options.digitHeight * options.digitImages);
return function _move() {
mtop = margin(elem) + options.digitHeight;
if (mtop == options.digitHeight) {
margin(elem, digits[elem]._digitInitial);
if (elem > 0) moveStep(elem - 1)();
else
{
clearInterval(interval);
for (var i=0; i < digits.length; i++) margin(i, 0);
options.timerEnd();
var match_link = digits[elem].parent().parent().parent().children('.match-info').children('a:first-child').attr('href');
digits[elem].parent().parent().html('<a href="'+match_link+'" class="live-now"><img width="145" height="35" src="http://files.barcelonastream.com/media-resources/other/WatchNow.png" class="attachment-medium" alt="WatchNow" title="WatchNow"></a>');
return;
}
if ((elem > 0) && (digits[elem].__condmax !== undefined) &&
(digits[elem - 1]._digitInitial == margin(elem - 1)))
margin(elem, -(digits[elem].__condmax * options.digitHeight * options.digitImages));
return;
}
margin(elem, mtop);
if (margin(elem) / options.digitHeight % options.digitImages != 0)
setTimeout(_move, options.stepTime);
if (mtop == 0) digits[elem].__ismax = true;
}
};
jQuery.extend(options, userOptions);
this.css({height: options.digitHeight, overflow: 'hidden'});
createDigits(this);
interval = setInterval(moveStep(digits.length - 1), 1000);
};
function timeleft(eventTime) {
var now = new Date();
var now_utc = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
var event_time = new Date(eventTime);
var t1 = now_utc.getTime();
//removes one hour from the date - 60 minutes * 60 seconds * 1000 miliseconds - -60*60*1000
var t2 = event_time.getTime();
var time_left = new Date(parseInt(t2-t1));
if(time_left<0) {
return "00:00:00:00";
}
msPerDay = 24 * 60 * 60 * 1000;
days = Math.floor(time_left/msPerDay);
if (days < 10) { days = "0"+days; }
hours = time_left.getUTCHours();
if (hours < 10) { hours = "0"+hours;}
minutes = time_left.getUTCMinutes();
if (minutes < 10) { minutes = "0"+minutes; }
seconds = time_left.getUTCSeconds();
if (seconds < 10) { seconds = "0"+seconds; }
return(days+":"+hours+":"+minutes+":"+seconds);
}
</script>
</head>
<body>
<div id="sct_id_0" class="simple_countdown_timer" style="width: 150px; margin: auto;">
<div class="sct_count" style="height: 19px; vertical-align: middle; overflow: hidden;"></div>
<div class="desc c1">
<div>days</div>
<div>hours</div>
<div>min</div>
<div class="secs">sec</div>
<script type="text/rocketscript">
jQuery(function(){
jQuery('#sct_id_0 .sct_count').countdown({
image: 'http://i.imgur.com/4Xw40YA.png',
format: "dd:hh:mm:ss",
// Jan,19,2015,16:00
eventTime: "Sep,29,2015,18:45",
digitWidth: 13,
digitHeight: 19,
});
});
</script></div>
</div>
Script code Not working in stackoverflow so i iframe this script
<iframe src="http://realmadridlive.in/mrk-schedule.php" /></iframe>
</body>
</html>
如果我理解对了,你可以使用。html函数https://jsfiddle.net/3ws247hh/
$('#sct_id_0').html("<img src='http://findicons.com/icon/download/169459/alert/128/png' /> ")