在同一页面中使用JQuery和Prototype;需要更多解释!

发布于 2024-08-27 05:06:41 字数 2425 浏览 7 评论 0原文

当我使用 jquery lightbox (运行原型)和 jquery news slider 时,我不断遇到问题。

我尝试了“无冲突”方法。

问题是我不知道放置代码的确切位置。

所以,在这里,我将我的脚本放入 .

因此,请对其进行故障排除并解释我将补丁放在哪里。

非常感谢。

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>Jquery</title> 

<script type="text/javascript" src="lb/js/prototype.js"></script>
<script type="text/javascript" src="lb/js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="lb/js/lightbox.js"></script>
<link href="lb/css/lightbox.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="news/jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="news/jquery.easynews.js"></script>



<style>
html
{ background-color: #FFA928;
font: normal 76% "Arial", "Lucida Grande",Verdana,  Sans-Serif;
 color:black;
 }
a { text-decoration: none; font-weight: bold; }

.news_style{
display:none;
}
.news_show
{
background-color: white;
color:black;
width:350px;
height:150px;
font: normal 100% "Arial", "Lucida Grande",Verdana,  Sans-Serif;
overflow: auto; 

}
.news_border
{
background-color: white;
width:350px;
height:150px;
font: normal 100% "Arial", "Lucida Grande",Verdana,  Sans-Serif;
border: 1px solid gray;
padding: 5px 5px 5px 5px;
overflow: auto; 

}
.news_mark{
background-color:white ;
font: normal 70% "Arial", "Lucida Grande",Verdana,  Sans-Serif;
border: 0px solid gray;
width:361px;
height:35px;
color:black;
text-align:center;
}
.news_title{
font: bold 120% "Arial", "Lucida Grande",Verdana,  Sans-Serif;
border: 0px solid gray;
padding: 5px 0px 9px 5px;
color:black;
}
.news_show img{

margin-left: 5px;
margin-right: 5px;

}
.buttondiv
{
position: absolute;
/*float: left;*/
/*top: 169px;*/
padding: 5px 5px 5px 5px;
background-color:white ;
border: 1px solid gray;
/*border-top-color: white;*/
border-top:none;
height:20px;
}

</style>
<script>
$(document).ready(function(){
var newsoption1 = {
  firstname: "mynews",
  secondname: "showhere",
  thirdname:"news_display",
  fourthname:"news_button",
   newsspeed:'6000'
}
$.init_news(newsoption1);


var myoffset=$('#news_button').offset();

var mytop=myoffset.top-1;

$('#news_button').css({top:mytop});

});
</script>

</head>

I'm continuously having the problem when i use jquery lightbox (which runs prototype) and jquery news slider.

I tried the "noconflict" method.

The problem is I don't know the exact place to put the code.

So, here, i'm putting my scripts within .

So, please troubleshoot it and explain me where to put the patch.

thank you very much.

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>Jquery</title> 

<script type="text/javascript" src="lb/js/prototype.js"></script>
<script type="text/javascript" src="lb/js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="lb/js/lightbox.js"></script>
<link href="lb/css/lightbox.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="news/jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="news/jquery.easynews.js"></script>



<style>
html
{ background-color: #FFA928;
font: normal 76% "Arial", "Lucida Grande",Verdana,  Sans-Serif;
 color:black;
 }
a { text-decoration: none; font-weight: bold; }

.news_style{
display:none;
}
.news_show
{
background-color: white;
color:black;
width:350px;
height:150px;
font: normal 100% "Arial", "Lucida Grande",Verdana,  Sans-Serif;
overflow: auto; 

}
.news_border
{
background-color: white;
width:350px;
height:150px;
font: normal 100% "Arial", "Lucida Grande",Verdana,  Sans-Serif;
border: 1px solid gray;
padding: 5px 5px 5px 5px;
overflow: auto; 

}
.news_mark{
background-color:white ;
font: normal 70% "Arial", "Lucida Grande",Verdana,  Sans-Serif;
border: 0px solid gray;
width:361px;
height:35px;
color:black;
text-align:center;
}
.news_title{
font: bold 120% "Arial", "Lucida Grande",Verdana,  Sans-Serif;
border: 0px solid gray;
padding: 5px 0px 9px 5px;
color:black;
}
.news_show img{

margin-left: 5px;
margin-right: 5px;

}
.buttondiv
{
position: absolute;
/*float: left;*/
/*top: 169px;*/
padding: 5px 5px 5px 5px;
background-color:white ;
border: 1px solid gray;
/*border-top-color: white;*/
border-top:none;
height:20px;
}

</style>
<script>
$(document).ready(function(){
var newsoption1 = {
  firstname: "mynews",
  secondname: "showhere",
  thirdname:"news_display",
  fourthname:"news_button",
   newsspeed:'6000'
}
$.init_news(newsoption1);


var myoffset=$('#news_button').offset();

var mytop=myoffset.top-1;

$('#news_button').css({top:mytop});

});
</script>

</head>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

并安 2024-09-03 05:06:41

我不知道你能比这里的解释更清楚

本质上,调用jQuery.noConflict$ 变量放弃为加载 jQuery 之前定义的任何内容。

之后需要调用jQuery才能直接使用。就我而言,我像这样重新定义它:

$j = jQuery; // Now I can use $j for jQuery and $ for Prototype

您还可以在就绪函数中使用 $,如下所示:

jQuery(document).ready(function($) {
  // Code that uses jQuery's $ can follow here.
});

非常简单......您对什么感到困惑?

I don't know how much clearer you can get then the explanation here

In essence, calling jQuery.noConflict relinquishes the $ variable to whatever it was defined as before you loaded jQuery.

After that you need to call jQuery to use it directly. In my case I redefine it like so:

$j = jQuery; // Now I can use $j for jQuery and $ for Prototype

You can also use the $ inside a ready function, like so:

jQuery(document).ready(function($) {
  // Code that uses jQuery's $ can follow here.
});

Pretty straightforward... what are you confused about?

━╋う一瞬間旳綻放 2024-09-03 05:06:41

呃? jQuery lightbox 不使用原型。你到底在用什么?

试试这个 http://leandrovieira.com/projects/jquery/lightbox/

并转储原型如果可以的话,一起。最好避免两个庞大的框架。

Eh? jQuery lightbox doesn't use prototype. What exactly are you using?

Try this http://leandrovieira.com/projects/jquery/lightbox/

And dump prototype all together if you can. Better to avoid two bulky frameworks.

浅忆 2024-09-03 05:06:41

在包含 jquery 库后立即调用 $.noConflict() 。请参阅此处

<script type="text/javascript" src="news/jquery-1.2.3.pack.js"></script>
<script type="text/javascript">
  $.noConflict();
  // Code that uses other library's $ can follow here.
</script>

Put the $.noConflict() call immediately after you include the jquery lib. See here.

<script type="text/javascript" src="news/jquery-1.2.3.pack.js"></script>
<script type="text/javascript">
  $.noConflict();
  // Code that uses other library's $ can follow here.
</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文