I'm including some lines of Javascript code in a Drupal page with input format as full html. The script works perfectly in Firefox and Chrome, but IE (7) fails with
'Object doesn't support this property or method'
this is the exact code I'm inserting in the Drupal page:
<link rel="开发者_JAVA技巧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',{
This probably is not a very orthodox way of including a custom javascript in a Drupal page. How should I do it, and how can I make it work with IE?
I'd suggest transferring the .noConflict()
call right after the <script>
tag for jQuery, and switching application/javascript
to text/javascript
(though I'm not really sure about application/javascript
--- just never used it before).
<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>
Also, you may want to double check your matcher
variable in the JSON object you pass in. I'm assuming that might be a string you're passing in, so you might have to pass that in as matcher : '/./'
.
精彩评论