.net 中JavaScript在IE浏览器中显示不出动态效果

初学.net就受阻,一个月后被逼无赖,终于把问题解决!

代码如下:

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head runat="server">
  5.     <title>无标题页</title>
  6.     <style type="text/css"> 
  7. BODY,UL  {
  8. PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
  9. }
  10. .container {
  11. WIDTH: 170px; HEIGHT: 205px
  12. }
  13. .container A IMG {
  14. WIDTH:170px; HEIGHT: 205px
  15. }
  16. .container IMG {
  17. BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-TOP-STYLE: none; BORDER-LEFT-STYLE: none
  18. }
  19. .td_f A IMG {
  20. PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
  21. }
  22. .num {
  23. POSITION: absolute; WIDTH: 90px; FLOAT: right; TOP: 180px; LEFT: 0px
  24. }
  25. .num LI {
  26. TEXT-ALIGN: center; LINE-HEIGHT: 15px; LIST-STYLE-TYPE: none; MARGIN: 1px; WIDTH: 15px; FONT-FAMILY: Arial; BACKGROUND: url(http://pc.qq.com/pc/images/flashbutton.gif) no-repeat -15px 0px; FLOAT: left; HEIGHT: 15px; COLOR: #86a2b8; FONT-SIZE: 12px; CURSOR: pointer
  27. }
  28. .num LI.on {
  29. LINE-HEIGHT: 15px; WIDTH: 15px;  HEIGHT: 15px; COLOR: #ffffff
  30. }
  31. .more {
  32. FLOAT: right
  33. }
  34. .more1 A {
  35. TEXT-ALIGN: left; LINE-HEIGHT: 25px; MARGIN: 0px 0px 0px 10px; COLOR: #3373a3
  36. }
  37. </style>
  38.     <script language="javascript" type="text/javascript">
  39.         if(typeof(pgvMain) == 'function')
  40.                 pgvMain();
  41.     </script>
  42.     <script language="javascript" type="text/javascript">
  43. var gtopTab="one";
  44. function $id(id)
  45. {
  46. return document.getElementById(id);
  47. }
  48. function changesTab(tab_id)
  49. {
  50. if (tab_id==gtopTab)
  51. {
  52. return;
  53. }else
  54. {
  55. $id(gtopTab).className="unselect";
  56. $id(tab_id).className="select";
  57. $id("tab_"+gtopTab).style.display="none";
  58. $id("tab_"+tab_id).style.display="block";
  59. gtopTab=tab_id;
  60. }
  61. }
  62.     </script>
  63.     <script language="javascript" type="text/javascript">
  64. var $ = function (id) 
  65. {
  66. return "string" == typeof id ? document.getElementById(id) : id;
  67. };
  68. var Extend = function(destination, source)
  69.  {
  70. for (var property in source) 
  71. {
  72. destination[property] = source[property];
  73. }
  74. return destination;
  75. }
  76. var CurrentStyle = function(element)
  77. {
  78. return element.currentStyle || document.defaultView.getComputedStyle(element, null);
  79. }
  80. var Bind = function(object, fun) 
  81. {
  82. var args = Array.prototype.slice.call(arguments).slice(2);
  83. return function() 
  84. {
  85. return fun.apply(object, args.concat(Array.prototype.slice.call(arguments)));
  86. }
  87. }
  88. var Tween = 
  89. {
  90. Quart: {
  91. easeOut: function(t,b,c,d){
  92. return -c * ((t=t/d-1)*t*t*t - 1) + b;
  93. }
  94. },
  95. Back: {
  96. easeOut: function(t,b,c,d,s){
  97. if (s == undefined) s = 1.70158;
  98. return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
  99. }
  100. },
  101. Bounce: {
  102. easeOut: function(t,b,c,d){
  103. if ((t/=d) < (1/2.75)) {
  104. return c*(7.5625*t*t) + b;
  105. } else if (t < (2/2.75)) {
  106. return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
  107. } else if (t < (2.5/2.75)) {
  108. return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
  109. } else {
  110. return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
  111. }
  112. }
  113. }
  114. }
  115. //容器对象,滑动对象,切换数量
  116. var SlideTrans = function(container, slider, count, options) {
  117. this._slider = $(slider);
  118. this._container = $(container);//容器对象
  119. this._timer = null;//定时器
  120. this._count = Math.abs(count);//切换数量
  121. this._target = 0;//目标值
  122. this._t = this._b = this._c = 0;//tween参数
  123. this.Index = 0;//当前索引
  124. this.SetOptions(options);
  125. this.Auto = !!this.options.Auto;
  126. this.Duration = Math.abs(this.options.Duration);
  127. this.Time = Math.abs(this.options.Time);
  128. this.Pause = Math.abs(this.options.Pause);
  129. this.Tween = this.options.Tween;
  130. this.onStart = this.options.onStart;
  131. this.onFinish = this.options.onFinish;
  132. var bVertical = !!this.options.Vertical;
  133. this._css = bVertical ? "top" : "left";//方向
  134. //样式设置
  135. var p = CurrentStyle(this._container).position;
  136. p == "relative" || p == "absolute" || (this._container.style.position = "relative");
  137. this._container.style.overflow = "hidden";
  138. this._slider.style.position = "absolute";
  139. this.Change = this.options.Change ? this.options.Change :
  140. this._slider[bVertical ? "offsetHeight" : "offsetWidth"] / this._count;
  141. };
  142. SlideTrans.prototype = {
  143.   //设置默认属性
  144.   SetOptions: function(options) {
  145. this.options = {//默认值
  146. Vertical: true,//是否垂直方向(方向不能改)
  147. Auto: true,//是否自动
  148. Change: 0,//改变量
  149. Duration: 50,//滑动持续时间
  150. Time: 10,//滑动延时
  151. Pause: 4000,//停顿时间(Auto为true时有效)
  152. onStart: function(){},//开始转换时执行
  153. onFinish: function(){},//完成转换时执行
  154. Tween: Tween.Quart.easeOut//tween算子
  155. };
  156. Extend(this.options, options || {});
  157.   },
  158.   //开始切换
  159.   Run: function(index) 
  160.   {
  161. //修正index
  162. index == undefined && (index = this.Index);
  163. index < 0 && (index = this._count - 1) || index >= this._count && (index = 0);
  164. //设置参数
  165. this._target = -Math.abs(this.Change) * (this.Index = index);
  166. this._t = 0;
  167. this._b = parseInt(CurrentStyle(this._slider)[this.options.Vertical ? "top" : "left"]);
  168. this._c = this._target - this._b;
  169. this.onStart();
  170. this.Move();
  171. this.Move();
  172.   },
  173.   //移动
  174.   Move: function() 
  175.   {
  176. clearTimeout(this._timer);
  177. if (this._c && this._t < this.Duration) 
  178. {
  179. this.MoveTo(Math.round(this.Tween(this._t++, this._b, this._c, this.Duration)));
  180. this._timer = setTimeout(Bind(this, this.Move), this.Time);
  181. }
  182. else
  183. {
  184. this.MoveTo(this._target);
  185. this.Auto && (this._timer = setTimeout(Bind(this, this.Next), this.Pause));
  186. }
  187.   },
  188.   //移动到
  189.   MoveTo: function(i)
  190.    {
  191. this._slider.style[this._css] = i + "px";
  192.   },
  193.   //下一个
  194.   Next: function()
  195.    {
  196. this.Run(++this.Index);
  197.   },
  198.   //上一个
  199.   Previous: function() {
  200. this.Run(--this.Index);
  201.   },
  202.   //停止
  203.   Stop: function() 
  204.   {
  205. clearTimeout(this._timer); this.MoveTo(this._target);
  206.   }
  207. };
  208.     </script>
  209. </head>
  210. <body>
  211.     <table width="183" border="0" cellspacing="0" cellpadding="0" style="height: 748px">
  212.         <tr>
  213.             <%--相册获果--%>
  214.             <td>
  215.                 <div id="idContainer2" class="container">
  216.                     <table id="idSlider2" border="0" cellspacing="0" cellpadding="0">
  217.                         <tr>
  218.                             <td class="td_f">
  219.                                 <a οnclick="pgvSendClick({hottag:'ISD.SHOW.BANNER.SOFTMGR'});" href="">
  220.                                     <img src="images/up01.jpg" alt="" /></a></td>
  221.                             <td class="td_f">
  222.                                 <a οnclick="pgvSendClick({hottag:'ISD.SHOW.BANNER.PY'});" href="">
  223.                                     <img src="images/up02.jpg" alt="" /></a></td>
  224.                             <td class="td_f">
  225.                                 <a οnclick="pgvSendClick({hottag:'ISD.SHOW.BANNER.PLAYER'});" href="">
  226.                                     <img src="images/up04.jpg" alt="" /></a></td>
  227.                             <td class="td_f">
  228.                                 <a οnclick="pgvSendClick({hottag:'ISD.SHOW.BANNER.XF'});" href="">
  229.                                     <img src="images/up05.jpg" alt="" /></a></td>
  230.                             <td class="td_f">
  231.                                 <a οnclick="pgvSendClick({hottag:'ISD.SHOW.BANNER.TT'});" href="">
  232.                                     <img src="images/up06.jpg" alt="" /></a></td>
  233.                         </tr>
  234.                     </table>
  235.                     <ul id="idNum" class="num">
  236.                         <script language="javascript" type="text/javascript">
  237. var forEach = function(array, callback, thisObject)
  238. {
  239. if(array.forEach){
  240. array.forEach(callback, thisObject);
  241. }
  242. else
  243. {
  244. for (var i = 0, len = array.length; i < len; i++) 
  245. {
  246. callback.call(thisObject, array[i], i, array); 
  247. }
  248. }
  249. }
  250. var st = new SlideTrans("idContainer2", "idSlider2", 5, { Vertical: false });
  251. var nums = [];
  252. //插入数字
  253. for(var i = 0, n = st._count - 1; i <= n;)
  254. {
  255. (nums[i] = $("idNum").appendChild(document.createElement("li"))).innerHTML = ++i;
  256. }
  257. forEach(nums, function(o, i)
  258. {
  259. o.onmouseover = function()
  260. {
  261. o.className = "on"; st.Auto = false; st.Run(i); 
  262. }
  263. o.onmouseout = function()
  264. {
  265. o.className = ""; st.Auto = true; st.Run(); 
  266. }
  267. })
  268. //设置按钮样式
  269. st.onStart = function()
  270. {
  271. forEach(nums, function(o, i){ o.className = st.Index == i ? "on" : ""; })
  272. }
  273. st.Run();
  274.                         </script>
  275.                     </ul>
  276.                 </div>
  277.             </td>
  278.         </tr>
  279.         <tr><td>asdfsadf</td></tr>
  280.         <tr><td>asdfsadf</td></tr>
  281.     </table>
  282. </body>
  283. </html>

最后发现是当时没有写第3行代码,因为我的代码是从别人那里拷的。
<!DOCTYPE>:

定义和用法

<!DOCTYPE> 声明位于文档中的最前面的位置,处于 <html> 标签之前。此标签可告知浏览器文档使用哪种 HTML 或 XHTML 规范。

该标签可声明三种 DTD 类型,分别表示严格版本、过渡版本以及基于框架的 HTML 文档。

以下面这个 <!DOCTYPE> 标签为例:

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

在上面的声明中,声明了文档的根元素是 html,它在公共标识符被定义为 "-//W3C//DTD XHTML 1.0 Strict//EN" 的 DTD 中进行了定义。浏览器将明白如何寻找匹配此公共标识符的 DTD。如果找不到,浏览器将使用公共标识符后面的 URL 作为寻找 DTD 的位置。

 

HTML

HTML 4.01 规定了三种文档类型:Strict、Transitional 以及 Frameset。

HTML Strict DTD

如果您需要干净的标记,免于表现层的混乱,请使用此类型。请与层叠样式表(CSS)配合使用:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd">

HTML Transitional DTD

Transitional DTD 可包含 W3C 所期望移入样式表的呈现属性和元素。如果您的读者使用了不支持层叠样式表(CSS)的浏览器以至于您不得不使用 HTML 的呈现特性时,请使用此类型:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">

Frameset DTD

Frameset DTD 应当被用于带有框架的文档。除 frameset 元素取代了 body 元素之外,Frameset DTD 等同于 Transitional DTD:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "
http://www.w3.org/TR/html4/frameset.dtd">

XHTML

XHTML 1.0 规定了三种 XML 文档类型:Strict、Transitional 以及 Frameset。

XHTML Strict DTD

如果您需要干净的标记,免于表现层的混乱,请使用此类型。请与层叠样式表(CSS)配合使用:

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

XHTML Transitional DTD

Transitional DTD 可包含 W3C 所期望移入样式表的呈现属性和元素。如果您的读者使用了不支持层叠样式表(CSS)的浏览器以至于您不得不使用 XHTML 的呈现特性时,请使用此类型:

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

XHTML Frameset DTD

当您希望使用框架时,请使用此 DTD!

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

如需检查你是否编写了带有正确 DTD 的合法 XHTML 文档,您可以把您的 XHTML 页面链接到一个 XHTML 验证器。

 

IE必需明确申明为XHTML才可以显示正常,我不过我仍然不特别明确这个标志的意义,希望高人路过可以指点迷津!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

秦剑

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值