日期:2014-05-17  浏览次数:20501 次

一段JS代码和JQUERY代码冲突了。求帮我改一下下
HTML code

function $(id) { return document.getElementById(id); }

function addLoadEvent(func){
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function(){
            oldonload();
            func();
        }
    }
}



就是这段。 和我其他代码段中的JQUERY冲突了。
能不能将它改成 JQUERY的形式

------解决方案--------------------
HTML code

<!--ie ff测试成功,以改成jq写法了-->
<!--把这一句<script type="text/javascript" src="jquery-1.3.2.min.js"></script>换成你的jquery路径-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>iFocus焦点图片轮换JS版_鎳掍汉鍥惧簱</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<style type="text/css">
/* Reset style */
* { margin:0; padding:0; word-break:break-all; }
body { background:#FFF; color:#333; font:12px/1.6em Helvetica, Arial, sans-serif; }
h1, h2, h3, h4, h5, h6 { font-size:1em; }
a { color:#0287CA; text-decoration:none; }
    a:hover { text-decoration:underline; }
ul, li { list-style:none; }
fieldset, img { border:none; }
legend { display:none; }
em, strong, cite, th { font-style:normal; font-weight:normal; }
input, textarea, select, button { font:12px Helvetica, Arial, sans-serif; }
table { border-collapse:collapse; }
html { overflow:-moz-scrollbars-vertical; } /*Always show Firefox scrollbar*/

/* iFocus style */
#ifocus { width:525px; height:245px; margin:20px; border:1px solid #DEDEDE; background:#F8F8F8; }
    #ifocus_pic { display:inline; position:relative; float:left; width:410px; height:225px; overflow:hidden; margin:10px 0 0 10px; }
        #ifocus_piclist { position:absolute; }
        #ifocus_piclist li { width:410px; height:225px; overflow:hidden; }
        #ifocus_piclist img { width:410px; height:225px; }
    #ifocus_btn { display:inline; float:right; width:91px; margin:9px 9px 0 0; }
        #ifocus_btn li { width:91px; height:57px; cursor:pointer; opacity:0.5; -moz-opacity:0.5; filter:alpha(opacity=50); }
        #ifocus_btn img { width:75px; height:45px; margin:7px 0 0 11px; }
        #ifocus_btn .current { background: url(http://www.iemay.com/templates/emay02082321/images/ifocus_btn_bg.gif) no-repeat; opacity:1; -moz-opacity:1; filter:alpha(opacity=100); }
    #ifocus_opdiv { position:absolute; left:0; bottom:0; width:410px; height:35px; background:#000; opacity:0.5; -moz-opacity:0.5; filter:alpha(opacity=50); }
    #ifocus_tx { position:absolute; left:8px; bottom:8px; color:#FFF; }
        #ifocus_tx .normal { display:none; }
</style>

<script type="text/javascript">
function addLoadEvent(func){
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function(){
            oldonload();
            func();
        }
    }
}

function moveElement(elementID,final_x,final_y,interval) {
  if (!document.getElementById) return false;
  if (!document.getElementById(elementID)) return false;
  var elem = document.getElementById(elementID);
  if (elem.movement) {
    clearTimeout(elem.movement);
  }
  if (!elem.style.left) {
    elem.style.left = "0px";
  }
  if (!elem.style.top) {
    elem.style.top = "0px";
  }
  var xpos = parseInt(elem.style.left);
  var ypos = parseInt(elem.style.top);
  if (xpos == final_x && ypos == final_y) {
        return true;
  }
  if (xpos < final_x) {
    var dist = Math.ceil((final_x - xpos)/10);
    xpos = xpos + dist;
  }
  if (xpos > final_x) {
    var dist = Math.ceil((x