JQUERY和YUI混用出现的问题

有道是一山不容二虎,其实我本不该把JQUERY和YUI夹杂在一块使用,虽然它们各有长短,结合使用的确能够相得益彰,但是暗地里还存着什么矛盾和冲突,这就不是随便刷新一下网页能够看出来的。
列一下最近碰到的问题,备忘。
混用时,YUI的Event在ie6下表现异常
下面代码中,没能在window.onload事件中弹出一个alert弹出窗口。
PLAIN TEXT
CODE:

<script>

YAHOO.util.Event.on(window, 'load', function() {alert('hello');});

</script>

猜想是jQuery重写了window.onload事件引起冲突,解决办法,使用jQuery的event。
PLAIN TEXT
CODE:

<script>

jQuery.event.add(window, "load", function() {alert('hello');});

</script>

评论 (2)

jquery和greasemonkey齐上阵

jquery写起来真的很简单,连我这刚接触jquery不久的新人都能很快用它码出大段的javascript。唯一的坏处是代码里充斥了大量的$。既然写javascript如此简单,那么用jquery+greasemonkey插件同时干活怎么样呢?
这里是一段提醒jquery已经载入的脚本,为了避免和页面上原有的代码冲突,得运行$.noConflict().
PLAIN TEXT
CODE:

// All your GM code must be inside this function

function letsJQuery() {

//make sure there is no conflict between jQuery and other libraries

$.noConflict()

//notify that jQuery is running...

  $('<div>jQuery is running!</div>')

    .css({padding: '10px', background: '#ffc', position: 'absolute',top: '0', width: '100%'})

    .prependTo('body')

    .fadeIn('fast')

    .animate({opacity: 1.0}, 300)

    .fadeOut('fast', function() {

      $(this).remove();

    [...]

评论 (4)