javascript 未捕获的类型错误:对象 [object Object] 没有方法 'overlay'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8547138/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught TypeError: Object [object Object] has no method 'overlay'
提问by humanbeing
Why do I get this error from my overlay jquery code?
为什么我的覆盖 jquery 代码会出现此错误?
This is the code:
这是代码:
jQuery(document).ready(function($) {
// if the function argument is given to overlay,
// it is assumed to be the onBeforeLoad event listener
$("a[rel]").overlay({
mask: 'darkred',
effect: 'apple',
onBeforeLoad: function() {
// grab wrapper element inside content
var wrap = this.getOverlay().find(".contentWrap");
// load the page specified in the trigger
wrap.load(this.getTrigger().attr("href"));
}
});
});
This code is the overlay like this: http://flowplayer.org/tools/demos/overlay/external.html
这段代码是这样的叠加:http: //flowplayer.org/tools/demos/overlay/external.html
Halp?
哈?
ps. Sorry for my bad english.
附:对不起,我的英语不好。
回答by chrisboy
"Could not find Overlay: nofollow" is caused by using a non-specific css selector to find the links you want to attach your overlay to.
“找不到覆盖:nofollow”是由于使用非特定的 css 选择器来查找要附加覆盖的链接造成的。
Including the javascript properly was the correct answer to the initial question... I came to this page based on the Overlay: nofollow issue in a comment.... since this is the first thing I found and didn't find an answer I wanted to comment here since I found it is caused by the css selector finding other uses of .. and there isn't a nofollow overlay...
正确包含 javascript 是最初问题的正确答案......我来到这个页面是基于 Overlay: nofollow 问题在评论中......因为这是我发现的第一件事并且没有找到答案我想在这里发表评论,因为我发现它是由 css 选择器发现 .. 的其他用途引起的,并且没有 nofollow 覆盖...
assuming 'overlay' is the id of your div as in the following:
假设 'overlay' 是您的 div 的 id,如下所示:
<!-- overlayed element -->
<div class="apple_overlay" id="overlay">
< !-- the external content is loaded inside this tag -- >
<div class="contentWrap"></div>
</div>
you should be doing something like:
你应该做这样的事情:
$("a[rel=#overlay]").overlay(
instead of:
代替:
$("a[rel]").overlay(
回答by vol7ron
You need to load the overlay
plugin before jQuery will see it as part of the object; see below.
Note: the plugin must come after the jQuery script
您需要overlay
在 jQuery 将其视为对象的一部分之前加载插件;见下文。
注意:插件必须在 jQuery 脚本之后
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="http://cdn.jquerytools.org/1.2.6/all/jquery.tools.min.js"></script>
回答by Hexodus
Got the same problem and found a really strange solution. I just included jquery.tools beforejquery.ui in this way:
遇到了同样的问题,并找到了一个非常奇怪的解决方案。我只是在jquery.ui之前以这种方式包含了 jquery.tools :
<script src='js/jquery-1.4.2.min.js' type='text/javascript'></script>
<script src='js/jquery.tools.min.js' type='text/javascript'></script>
<script src='js/jquery-ui-1.7.2.custom.min.js' type='text/javascript'></script>
That's all. No idea why it works now but it does the job.
就这样。不知道为什么它现在有效,但它可以完成工作。
回答by EKet
Did you include the overlay script src in your page?
您是否在页面中包含了覆盖脚本 src?