Pergunta

Atualmente estou usando o seguinte plugin jQuery: jQuery oEmbed. Este plugin funciona muito bem em FF, Chrome e Safari. No entanto, estou tendo um problema no IE7. Eu despojado meu código para baixo a muito bare-ossos, mas ainda não pode descobrir o que estaria fazendo com que o seguinte erro:

Error: Object doesn't support this property or method.

A linha do erro está se referindo é:

  $("#container").oembed("http://www.youtube.com/watch?v=nue4pvzuyOo");

Aqui está o meu HTML (novamente, muito básico):

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
    <title>jquery-oembed explicit insert example</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>    
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>  
    <script type="text/javascript" src="oe.js"></script>
  </head>
  <body>
   <script type="text/javascript">
    $(document).ready(function() {
            $("#container").oembed("http://www.youtube.com/watch?v=nue4pvzuyOo");

    });
  </script>
 <div id="container"></div>
 </body>
 </html>

O javascript para o plugin pode ser encontrada aqui .

Curiosamente, este erro não ocorre em IE8-- única IE7.

Algumas ideias sobre o que poderia estar causando esse erro?

Foi útil?

Solução

JSLint relatos de que, entre outros problemas, o código do plugin é ligada ao tem uma vírgula a mais dentro de um literal objeto . Corrigindo este parece corrigi-lo no IE7.

A correção:

// Plugin defaults
$.fn.oembed.defaults = {
    maxWidth: null,
    maxHeight: null,
            embedMethod: "replace", // "auto", "append", "fill"
};

muda para:

// Plugin defaults
$.fn.oembed.defaults = {
    maxWidth: null,
    maxHeight: null,
            embedMethod: "replace" // "auto", "append", "fill"
};

Observe a vírgula após "replace".

Working demonstração: http://jsbin.com/oxitu

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top