当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 找到了一篇jQuery与Prototype并存的冲突的解决方法

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 找到了一篇jQuery与Prototype并存的冲突的解决方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 65 ::
收藏到网摘: n/a

以前好像在哪里看到过说jQuery与prototype存在冲突,但一直没在意。今天把自己用jquery框架写好的消息提示框特效放到公司原来的系统发现所有的消息提示效果都罢工了!
汗了半天还是没有发现原因,突然想到jquery与prototype的冲突问题,这才发现公司原来的系统很多页面都调用了prototype框架。知道了原因就想办法解决吧,总不至于让我脱离jquery重新写一遍吧,去网上狂搜了一番终于找到了一些解决办法,这就是:
1、将jquery.js放到prototype.js后面(这个是必须的否则无论如何还是要罢工地)。
2、在jquery.js后面将$变量重命名。
方法如下:
复制代码 代码如下:

<script type="text/javascript" type="text/javascript" src="window.js"></script>
<!--上面这个window.js调用了jquery框架的方法-->
<script type="text/javascript" type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
var jQuery=$;
</script>

3、将原来使用的$方法名一律替换为jQuery名,如$("obj")替换为jQuery("obj")。
按照上面三步操作来进行问题很快就解决了。