我在 Drupal 页面中包含了一些 Javascript 代码行,输入格式为完整的 html。 该脚本在 Firefox 和 Chrome 中完美运行,但 IE (7) 失败并显示
'Object doesn't support this property or method'
这是我在 Drupal 页面中插入的确切代码:
<link rel="stylesheet" href="/scripts/gallery/jquery-1.6.1/css/slimbox2.css" type="text/css" media="screen" />
<script type="application/javascript" src="/scripts/gallery/jquery-1.6.1/jquery-1.6.1.js">
<script type="application/javascript" src="/scripts/gallery/jquery-1.6.1/slimbox2.js">
<script type="application/javascript" src="/scripts/gallery/jquery-1.6.1/jquery.EmbedPicasaGallery.js">
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery.noConflict();
jQuery("#pics").EmbedPicasaGallery('mygallery',{
matcher: /./,
loading_animation: 'css/loading.gif',
msg_back : 'Back',
size: '85'
});
});
</script>
<div id="pics" />
The javascript error occurrs on this line, at char 2:
jQuery("#pics").EmbedPicasaGallery('mygallery',{
这可能不是在 Drupal 页面中包含自定义 javascript 的非常正统的方法。 我应该怎么做,如何让它与 IE 一起工作?
最佳答案
我建议转移 .noConflict()
在 <script>
之后立即调用jQuery 标记和切换 application/javascript
至 text/javascript
(虽然我不太确定 application/javascript
--- 只是以前从未使用过它)。
<script type="text/javascript" src="/scripts/gallery/jquery-1.6.1/jquery-1.6.1.js">
<script type='text/javascript'>jQuery.noConflict();</script>
<script type="text/javascript" src="/scripts/gallery/jquery-1.6.1/slimbox2.js">
<script type="text/javascript" src="/scripts/gallery/jquery-1.6.1/jquery.EmbedPicasaGallery.js">
<script type='text/javascript'>
jQuery(function($) {
$('#pics').EmbedPicasaGallery({
// blah
});
});
</script>
此外,您可能需要仔细检查您的 matcher
您传入的 JSON 对象中的变量。我假设这可能是您传入的字符串,因此您可能必须将其作为 matcher : '/./'
传递.
关于javascript - jQuery、IE 7 对象不支持此属性或方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6422942/