jQuery在aspx页面中不起作用 [英] jQuery not working in aspx page

查看:74
本文介绍了jQuery在aspx页面中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,

问候!
我遇到了一个小问题,我无法找到最近两个小时的分辨率...我正在使用一个jquery文件在页面上显示一个模拟时钟. HTML代码如下:

Hi mates,

Greetings!
I''m stuck with a minor problem and I''ve been just unable to find the resolution for last two hours... I''m using a jquery file to display an analog clock on page. the HTML code is as below:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="usa.master.cs" Inherits="PostageMeter.usa" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>IN ADMIN PANEL | Powered by INDEZINER</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="clockp.js"></script>
<script type="text/javascript" src="clockh.js"></script>
</head>
<body>
<div id="clock_a"></div>
</body>
</html>



引用的jQuery文件内容:
============================
clockp.js
*********



Referred jQuery File contents:
==============================
clockp.js
*********

// Analog Clock - Parameters Head Script
// You may change the parameters here to set up your clock
// refer to  http://javascript.about.com/library/blclock1.htm
// for a description of the parameters
var clocksize=50;
var colnumbers='ffffff';
var colseconds='fff';
var colminutes='fff';
var colhours='fff';
var numstyle = 2;
var font_family = 'helvetica,arial,sans-serif';
var localZone = 1;
var mytimezone = 0;
var dst = 0;
var city = '';
var country = '';
var fix = 1;
var xpos=0;
var ypos=0;

// code to adjust for daylight saving time if applicable (localzone = 0)

// code to handle clock positioning (fix = 0)



clockh.js
*********



clockh.js
*********

报价:

//Analog Clock-Head Script
//版权斯蒂芬·查普曼(Stephen Chapman),2005年11月19日,2008年9月28日,
//如果您保留版权声明,可以复制此时钟
var dayname = new Array(``Sunday'',``Monday'',``Tuesday'',``Wednesday'',``Thursday'',``Friday'',``Saturday'',''星期日''); var am =``AM''; var pm =``PM'';

//您无需更改以下代码
var pi = Math.PI; var d = document; var pi2 = pi/2; var rad =(+ clocksize)/2; var ctrX =(+ xpos)+ rad; var ctrY =(+ ypos)+ rad; var hourln = 1; var minln = secln = 2; for(var i = 0; i<(rad/2)+(rad/16); i ++){horemovedn + = 1;} for(var i = 0; i<(rad/2)-(rad/8); i ++){minln + = 2; secln + = 2;} var font_size = rad/4; var offset = 16; var clocknum = [[,1,2,3,4,5,6,7,8,9,10,11,12],[,''I'',''II'',''III'' ,``IIII'',``V'',``VI'',``VII'',``VIII'',``IX'',``X'',``XI'',' 'XII''],[,''·'',''·'',``-'',``·'',``·'','' || '']];如果(numstyle< 0 || numstyle> 2)numstyle = 0;函数timeZone(now,loc,mtz,dst){if(loc){var dow = now.getDay(); var second = now.getSeconds(); var分钟= now.getMinutes(); var hour = now.getHours();}否则{now.setUTCMinutes(now.getUTCMinutes()+(mtz + dst)* 60);; var dow = now.getUTCDay(); var second = now.getUTCSeconds(); var分钟= now.getUTCMinutes(); var hour = now.getUTCHours();}如果(hour> 11){moa = pm;小时-= 12;}否则,moa = am; return [dow,moa,hour,minute,second];}函数commonClock(n){n.style.position ="absolute"; n.style.top =``0''; n.style.left =``0''; n.style.visibility ="hidden";}函数displayClock(){if(!d.getElementById)return; var ctx = document.createElement(''div''); if(fix){ctx.style.position =``相对''; ctx.style.margin =``自动''; ctx.style.width =(clocksize + offset * 2)+``px''; ctx.style.height =(clocksize + offset * 2)+``px''; ctx.style.overflow ="visible";} var cn = []; for(var i = 12; i> 0; i--){cn [i] = document.createElement(''div''); cn [i] .id =``cnum''+ i; commonClock(cn [i]); cn [i] .style.width =(offset * 2)+``px''; cn [i] .style.height =(offset * 2)+``px''; cn [i] .style.fontFamily = font_family; cn [i] .style.fontSize = font_size +``px''; cn [i] .style.color =``#''+列数; cn [i] .style.textAlign =``中心''; cn [i] .style.paddingTop =``10px''; cn [i] .style.zIndex = 1000; cn [i] .innerHTML = clocknum [numstyle] [i]; ctx.appendChild(cn [i]);} var mn = [];对于(i = minln; i> 0; i--){mn [i] = document.createElement(''div''); mn [i] .id =``cmin''+ i; commonClock(mn [i]); mn [i] .style.width =``1px''; mn [i] .style.height =``1px''; mn [i] .style.fontSize =``1px''; mn [i] .style.backgroundColor =``#''+ colminutes; mn [i] .style.zIndex = 997; ctx.appendChild(mn [i]);} var hr = [];对于(i = hourln; i> 0; i--){hr [i] = document.createElement(''div''); hr [i] .id =``chour''+ i; commonClock(hr [i]); hr [i] .style.width =``2px''; hr [i] .style.height =``2px''; hr [i] .style.fontSize =''2px''; hr [i] .style.backgroundColor =``#''+ colhours; hr [i] .style.zIndex = 998; ctx.appendChild(hr [i]);} var sc = []; for(i = secln; i> 0; i--){sc [i] = document.createElement(''div''); sc [i] .id =``csec''+ i; commonClock(sc [i]); sc [i] .style.width =``1px''; sc [i] .style.height =``1px''; sc [i] .style.fontSize =''1px''; sc [i] .style.backgroundColor =``#''+ colseconds; sc [i] .style.zIndex = 999; ctx.appendChild(sc [i]);} var am = document.createElement(''div''); am.id =``ampm''; commonClock(am); am.style.width =((xpos + rad)* 2)+``px''; am.style.fontFamily = font_family; am.style.fontSize =(font_size * 2/3)+``px''; am.style.color =``#''+数字am.style.textAlign =``中心''; am.style.paddingTop =``10px''; am.style.zIndex = 990; ctx.appendChild(am); var zn = document.createElement(''div''); zn.id =``区域''; commonClock(zn); zn.style.width =((xpos + rad)* 2)+``px''; zn.style.fontFamily = font_family; zn.style.fontSize =(font_size * 2/3)+``px''; zn.style.color =``#''+列数; zn.style.textAlign =``中心''; zn.style.paddingTop =``10px''; zn.style.zIndex = 990; ctx.appendChild(zn); d.getElementById(''clock_a'').appendChild(ctx); for(var i = 12; i> 0; i--){d.getElementById(''cnum''+ i).style.top =(ctrY-偏移量+ rad * Math.sin(i * pi/6 -pi2))+''px''; d.getElementById(''cnum''+ i).style.left =(ctrX-偏移量+ rad * Math.cos(i * pi/6-pi2))+''px''; d.getElementById(``cnum''+ i).style.visibility ="visible";} updateClock();}函数moveClock(l,e,f){for(var i = l; i> 0 ; i--){d.getElementById(e + i).style.top =(ctrY + i * Math.sin(f))+''px''; d.getElementById(e + i).style.left =(ctrX + i * Math.cos(f))+''px''; d.getElementById(e + i).style.visibility ="visible'';}}函数updateClock(){var now = new日期(); var theTime = timeZone(now,localZone,mytimezone,dst); d.getElementById(''ampm​​'').style.top =(ypos + rad/3)+''px''; /*d.getElementById(''ampm​​'').innerHTML = theTime [1] +''
''+ dayname [theTime [0]]; */d.getElementById(''ampm​​'').style .visibility =``可见'';如果(!localZone){d.getElementById(``zone'').style.top =(ctrY +(rad/10))+''px''; d.getElementById(``zone'').innerHTML =城市+``
''+国家; d.getElementById("zone").style.visibility ="visible";} moveClock(secln,``csec'',pi * theTime [4]/30-pi2); moveClock(minln,``cmin'',pi * theTime [3]/30-pi2); moveClock(hourln,``chour'',pi * theTime [2]/6 + pi *(+ now.getMinutes())/360-pi2); setTimeout(''updateClock()'',100);}
window.onload = displayClock;

// Analog Clock - Head Script
// copyright Stephen Chapman, 19th November 2005, 28th September 2008
// you may copy this clock provided that you retain the copyright notice
var dayname = new Array (''Sunday'',''Monday'',''Tuesday'',''Wednesday'',''Thursday'',''Friday'',''Saturday'',''Sunday''); var am = ''AM''; var pm = ''PM'';

// you should not need to alter the below code
var pi = Math.PI; var d = document; var pi2 = pi/2; var rad = (+clocksize) / 2; var ctrX = (+xpos) + rad; var ctrY = (+ypos) + rad; var hourln = 1; var minln = secln = 2; for(var i = 0; i < (rad / 2) + (rad / 16); i++) {horemovedn += 1;} for(var i = 0; i < (rad / 2) - (rad / 8); i++) {minln += 2;secln += 2;} var font_size = rad / 4; var offset = 16; var clocknum = [[,1,2,3,4,5,6,7,8,9,10,11,12],[,''I'',''II'',''III'',''IIII'',''V'',''VI'',''VII'',''VIII'',''IX'',''X'',''XI'',''XII''],[,''·'',''·'',''-'',''·'',''·'',''|'',''·'',''·'',''-'',''·'',''·'',''||'']]; if (numstyle < 0 || numstyle > 2) numstyle = 0; function timeZone(now,loc,mtz,dst) {if (loc) {var dow = now.getDay(); var second = now.getSeconds(); var minute = now.getMinutes(); var hour = now.getHours();} else {now.setUTCMinutes(now.getUTCMinutes() + (mtz + dst)*60); var dow = now.getUTCDay(); var second = now.getUTCSeconds(); var minute = now.getUTCMinutes(); var hour = now.getUTCHours();} if (hour > 11) {moa = pm; hour -= 12;} else moa = am; return [dow,moa,hour,minute,second];} function commonClock(n) {n.style.position = ''absolute''; n.style.top = ''0''; n.style.left = ''0''; n.style.visibility = ''hidden'';} function displayClock() {if (!d.getElementById) return; var ctx = document.createElement(''div''); if ( fix) {ctx.style.position = ''relative''; ctx.style.margin = ''auto''; ctx.style.width = (clocksize + offset * 2) + ''px''; ctx.style.height = (clocksize + offset * 2) + ''px''; ctx.style.overflow = ''visible'';} var cn = []; for (var i = 12; i > 0; i--) {cn[i] = document.createElement(''div''); cn[i].id = ''cnum'' + i; commonClock(cn[i]); cn[i].style.width = (offset * 2) + ''px''; cn[i].style.height = (offset * 2) + ''px''; cn[i].style.fontFamily = font_family; cn[i].style.fontSize = font_size + ''px''; cn[i].style.color = ''#'' + colnumbers; cn[i].style.textAlign = ''center''; cn[i].style.paddingTop = ''10px''; cn[i].style.zIndex = 1000; cn[i].innerHTML = clocknum[numstyle][i]; ctx.appendChild(cn[i]);} var mn = []; for (i = minln; i > 0; i--) {mn[i] = document.createElement(''div''); mn[i].id = ''cmin'' + i; commonClock(mn[i]); mn[i].style.width = ''1px''; mn[i].style.height = ''1px''; mn[i].style.fontSize = ''1px''; mn[i].style.backgroundColor = ''#'' + colminutes; mn[i].style.zIndex = 997; ctx.appendChild(mn[i]);} var hr = []; for (i = hourln; i > 0; i--) {hr[i] = document.createElement(''div''); hr[i].id = ''chour'' + i; commonClock(hr[i]); hr[i].style.width = ''2px''; hr[i].style.height = ''2px''; hr[i].style.fontSize =''2px''; hr[i].style.backgroundColor = ''#'' + colhours; hr[i].style.zIndex = 998; ctx.appendChild(hr[i]);} var sc = []; for (i = secln; i > 0; i--) {sc[i] = document.createElement(''div''); sc[i].id = ''csec'' + i; commonClock(sc[i]); sc[i].style.width = ''1px''; sc[i].style.height = ''1px''; sc[i].style.fontSize =''1px''; sc[i].style.backgroundColor = ''#'' + colseconds; sc[i].style.zIndex = 999; ctx.appendChild(sc[i]);} var am = document.createElement(''div''); am.id = ''ampm''; commonClock(am); am.style.width = ((xpos + rad) * 2) + ''px''; am.style.fontFamily = font_family; am.style.fontSize = (font_size * 2 / 3) + ''px''; am.style.color = ''#'' + colnumbers; am.style.textAlign = ''center''; am.style.paddingTop = ''10px''; am.style.zIndex = 990; ctx.appendChild(am); var zn = document.createElement(''div''); zn.id = ''zone''; commonClock(zn); zn.style.width = ((xpos + rad) * 2) + ''px''; zn.style.fontFamily = font_family; zn.style.fontSize = (font_size * 2 / 3) + ''px''; zn.style.color = ''#'' + colnumbers; zn.style.textAlign = ''center''; zn.style.paddingTop = ''10px''; zn.style.zIndex = 990; ctx.appendChild(zn); d.getElementById(''clock_a'').appendChild(ctx); for (var i = 12; i > 0; i--) {d.getElementById(''cnum'' + i).style.top = (ctrY - offset + rad * Math.sin(i * pi / 6 - pi2))+''px''; d.getElementById(''cnum'' + i).style.left = (ctrX - offset + rad * Math.cos(i * pi / 6 - pi2))+''px''; d.getElementById(''cnum'' + i).style.visibility = ''visible'';} updateClock();} function moveClock(l, e, f) {for (var i = l; i > 0; i--) {d.getElementById(e + i).style.top = (ctrY + i * Math.sin(f))+''px'';d.getElementById(e + i).style.left = (ctrX + i * Math.cos(f))+''px'';d.getElementById(e + i).style.visibility = ''visible'';}} function updateClock() {var now = new Date(); var theTime = timeZone(now,localZone,mytimezone,dst); d.getElementById(''ampm'').style.top = (ypos + rad/3)+''px''; /*d.getElementById(''ampm'').innerHTML = theTime[1] + ''
'' + dayname[theTime[0]];*/ d.getElementById(''ampm'').style.visibility = ''visible''; if (!localZone) {d.getElementById(''zone'').style.top = (ctrY + (rad/10))+''px''; d.getElementById(''zone'').innerHTML = city + ''
'' + country; d.getElementById(''zone'').style.visibility = ''visible'';} moveClock(secln, ''csec'', pi * theTime[4] / 30 - pi2); moveClock(minln, ''cmin'', pi * theTime[3] / 30 - pi2); moveClock(hourln, ''chour'', pi * theTime[2] / 6 + pi * (+now.getMinutes())/360 - pi2); setTimeout(''updateClock()'', 100);}
window.onload = displayClock;




我在主页上粘贴的内容与jQuery文件放在根目录下一样,试图执行但没有运气. HTML页面可以正常工作,但ASPX不能.没有错误..没有输出.我从来没有经历过这种问题...请帮忙!!
感谢您的帮助.

最好的问候,
Sunny.




The same I''ve pasted in my master page with the jQuery file at root and trying to execute but no luck. The HTML page works fine but the ASPX not. No errors.. no output. I never have been through to this kind of problem... Please help !!
I appreciate any help.

Best Regards,
Sunny.

推荐答案


检查天气是否正确包含了Jquery库文件.如果是,则检查代码中是否存在任何语法错误.有时由于语法错误,它不会显示任何错误或异常.
Hi,
check weather you have included Jquery library files properly or not. If yes then check for any kind of syntax error in your code. sometimes it doesn''t show any error or exception due to syntax error.


我建​​议使用浏览器上可用的开发人员工具. (我个人的选择是Chrome)检查是否在后台发生了javascript错误,这些错误被系统吞噬,然后被系统隐藏.许多jquery问题都以这种方式解决了.我之所以只提一句,是因为从您的问题中我还无法确定您是否已经探索过这种途径.
I would suggest using the developer tools available on your browser. (My personal choice is Chrome) Check whether there are javascript errors occuring in the background that get gobbled up and then hidden by the system. Many a jquery problem gets solved in this manner. I only mention this because from your question I can''t make out whether you have explored this avenue yet.


我为您效劳,发现了一些小错误.从文件中删除了它们.然后使用新版本

clockp.js
*********
i tried for you and i found some little mistakes. removed them from file. then use new version

clockp.js
*********
// Analog Clock - Parameters Head Script
// You may change the parameters here to set up your clock
// refer to  http://javascript.about.com/library/blclock1.htm
// for a description of the parameters
var clocksize = 50;
var colnumbers = 'ffffff';
var colseconds = 'fff';
var colminutes = 'fff';
var colhours = 'fff';
var numstyle = 2;
var font_family = 'helvetica,arial,sans-serif';
var localZone = 1;
var mytimezone = 0;
var dst = 0;
var city = '';
var country = '';
var fix = 1;
var xpos = 0;
var ypos = 0;
var horemovedn = 0;

// code to adjust for daylight saving time if applicable (localzone = 0)

// code to handle clock positioning (fix = 0)



clockh.js
*********




clockh.js
*********


var dayname = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
var am = 'AM';
var pm = 'PM';

// you should not need to alter the below code
var pi = Math.PI;
var d = document;
var pi2 = pi / 2;
var rad = (+clocksize) / 2;
var ctrX = (+xpos) + rad;
var ctrY = (+ypos) + rad;
var hourln = 1;
var minln = secln = 2;
for (var i = 0; i < (rad / 2) + (rad / 16); i++) {
    horemovedn += 1;
}

for (var i = 0; i < (rad / 2) - (rad / 8); i++) {
    minln += 2; secln += 2;
}
var font_size = rad / 4;
var offset = 16;
var clocknum = [[, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [, 'I', 'II', 'III', 'IIII', 'V', 'VI', 'VII', 'VIII', 'IX', 'X', 'XI', 'XII'], [, '·', '·', '-', '·', '·', '|', '·', '·', '-', '·', '·', '||']];
if (numstyle < 0 || numstyle > 2)
    numstyle = 0;
function timeZone(now, loc, mtz, dst) {
    if (loc) {
        var dow = now.getDay();
        var second = now.getSeconds();
        var minute = now.getMinutes(); var hour = now.getHours();
    } else { now.setUTCMinutes(now.getUTCMinutes() + (mtz + dst) * 60); var dow = now.getUTCDay(); var second = now.getUTCSeconds(); var minute = now.getUTCMinutes(); var hour = now.getUTCHours(); } if (hour > 11) { moa = pm; hour -= 12; } else moa = am; return [dow, moa, hour, minute, second];
} function commonClock(n) { n.style.position = 'absolute'; n.style.top = '0'; n.style.left = '0'; n.style.visibility = 'hidden'; } function displayClock() {
    if (!d.getElementById) return; var ctx = document.createElement('div'); if (fix) { ctx.style.position = 'relative'; ctx.style.margin = 'auto'; ctx.style.width = (clocksize + offset * 2) + 'px'; ctx.style.height = (clocksize + offset * 2) + 'px'; ctx.style.overflow = 'visible'; } var cn = []; for (var i = 12; i > 0; i--) { cn[i] = document.createElement('div'); cn[i].id = 'cnum' + i; commonClock(cn[i]); cn[i].style.width = (offset * 2) + 'px'; cn[i].style.height = (offset * 2) + 'px'; cn[i].style.fontFamily = font_family; cn[i].style.fontSize = font_size + 'px'; cn[i].style.color = '#' + colnumbers; cn[i].style.textAlign = 'center'; cn[i].style.paddingTop = '10px'; cn[i].style.zIndex = 1000; cn[i].innerHTML = clocknum[numstyle][i]; ctx.appendChild(cn[i]); } var mn = []; for (i = minln; i > 0; i--) { mn[i] = document.createElement('div'); mn[i].id = 'cmin' + i; commonClock(mn[i]); mn[i].style.width = '1px'; mn[i].style.height = '1px'; mn[i].style.fontSize = '1px'; mn[i].style.backgroundColor = '#' + colminutes; mn[i].style.zIndex = 997; ctx.appendChild(mn[i]); } var hr = []; for (i = hourln; i > 0; i--) { hr[i] = document.createElement('div'); hr[i].id = 'chour' + i; commonClock(hr[i]); hr[i].style.width = '2px'; hr[i].style.height = '2px'; hr[i].style.fontSize = '2px'; hr[i].style.backgroundColor = '#' + colhours; hr[i].style.zIndex = 998; ctx.appendChild(hr[i]); } var sc = []; for (i = secln; i > 0; i--) { sc[i] = document.createElement('div'); sc[i].id = 'csec' + i; commonClock(sc[i]); sc[i].style.width = '1px'; sc[i].style.height = '1px'; sc[i].style.fontSize = '1px'; sc[i].style.backgroundColor = '#' + colseconds; sc[i].style.zIndex = 999; ctx.appendChild(sc[i]); } var am = document.createElement('div'); am.id = 'ampm'; commonClock(am); am.style.width = ((xpos + rad) * 2) + 'px'; am.style.fontFamily = font_family; am.style.fontSize = (font_size * 2 / 3) + 'px'; am.style.color = '#' + colnumbers; am.style.textAlign = 'center'; am.style.paddingTop = '10px'; am.style.zIndex = 990; ctx.appendChild(am); var zn = document.createElement('div'); zn.id = 'zone'; commonClock(zn); zn.style.width = ((xpos + rad) * 2) + 'px'; zn.style.fontFamily = font_family; zn.style.fontSize = (font_size * 2 / 3) + 'px'; zn.style.color = '#' + colnumbers; zn.style.textAlign = 'center'; zn.style.paddingTop = '10px'; zn.style.zIndex = 990; ctx.appendChild(zn); 

d.getElementById('clock_a').appendChild(ctx); for (var i = 12; i > 0; i--) { d.getElementById('cnum' + i).style.top = (ctrY - offset + rad * Math.sin(i * pi / 6 - pi2)) + 'px'; d.getElementById('cnum' + i).style.left = (ctrX - offset + rad * Math.cos(i * pi / 6 - pi2)) + 'px'; d.getElementById('cnum' + i).style.visibility = 'visible'; } updateClock(); } function moveClock(l, e, f) { for (var i = l; i > 0; i--) { d.getElementById(e + i).style.top = (ctrY + i * Math.sin(f)) + 'px'; d.getElementById(e + i).style.left = (ctrX + i * Math.cos(f)) + 'px'; d.getElementById(e + i).style.visibility = 'visible'; } }
function updateClock() {
    var now = new Date();
    var theTime = timeZone(now, localZone, mytimezone, dst);
    d.getElementById('ampm').style.top = (ypos + rad / 3) + 'px';
    /*d.getElementById('ampm').innerHTML = theTime[1] + '' + dayname[theTime[0]];*/
    d.getElementById('ampm').style.visibility = 'visible';
    if (!localZone) {
        d.getElementById('zone').style.top = (ctrY + (rad / 10)) + 'px';
        d.getElementById('zone').innerHTML = city + '' + country;
        d.getElementById('zone').style.visibility = 'visible';
    }
    moveClock(secln, 'csec', pi * theTime[4] / 30 - pi2); moveClock(minln, 'cmin', pi * theTime[3] / 30 - pi2); moveClock(hourln, 'chour', pi * theTime[2] / 6 + pi * (+now.getMinutes()) / 360 - pi2); setTimeout('updateClock()', 100);
}
window.onload = displayClock;



i made clock_a divs style background-color:Black, after then i saw the watch.

i hope it will solve the problem



i made clock_a divs style background-color:Black, after then i saw the watch.

i hope it will solve the problem


这篇关于jQuery在aspx页面中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆