jquery元素创建的结果与Firefox 14中的预期不符

jquery元素创建的结果与Firefox 14中的预期不符,jquery,html,firefox4,createelement,Jquery,Html,Firefox4,Createelement,我正在尝试清除一个div,并使用jquery在html5中重新填充一个pdf。它在Chrome上运行得很好,但Firefox14的表现似乎很奇怪。代码如下: $("#content").empty(); var newObject = $(document.createElement("object")); newObject.attr("id", "contentViewer"); /*var errorMessage = $(document.createElement("p")); $(e

我正在尝试清除一个div,并使用jquery在html5中重新填充一个pdf。它在Chrome上运行得很好,但Firefox14的表现似乎很奇怪。代码如下:

$("#content").empty();
var newObject = $(document.createElement("object"));
newObject.attr("id", "contentViewer");
/*var errorMessage = $(document.createElement("p"));
$(errorMessage).html(It appears you don't have a pdf plugin for this browser. No biggie... you can <a href="path-to-pdf.pdf">click here to download the pdf file.</a>);
$(newObject).append($(errorMessage));*/
$("#content").append($(newObject));
$(“#内容”).empty();
var newObject=$(document.createElement(“对象”);
attr(“id”,“contentViewer”);
/*var errorMessage=$(document.createElement(“p”);
$(errorMessage).html(看起来您没有此浏览器的pdf插件。没什么大不了的…您可以);
$(newObject).append($(errorMessage))*/
$(“#内容”).append($(newObject));
被注释掉的三个命令中断了Firefox。如果没有它们,页面将清除div,然后执行上面显示的代码。如果我把这三个命令放回去,它在被触发时不会做任何事情。Chrome不在乎,它只是在有或没有它的情况下工作

我想我有两个问题:

  • 我应该如何在Firefox中动态嵌入pdf(如果我在上面做得不正确)
  • 我是否有一个打字错误,我不知道上面的方法是否有效?还是被窃听了

  • 谢谢

    您错过了以下报价:

    $(errorMessage).html("It appears you don't have a pdf plugin for this browser. No biggie... you can <a href='path-to-pdf.pdf'>click here to download the pdf file.</a>");
    
    $(errorMessage.html(“您似乎没有此浏览器的pdf插件。没什么大不了的……您可以”);
    

    我不知道你的代码在chrome上是如何工作的。它应该抛出一个语法错误。

    您错过了引号:

    $(errorMessage).html("It appears you don't have a pdf plugin for this browser. No biggie... you can <a href='path-to-pdf.pdf'>click here to download the pdf file.</a>");
    
    $(errorMessage.html(“您似乎没有此浏览器的pdf插件。没什么大不了的……您可以”);
    

    我不知道你的代码在chrome上是如何工作的。它应该抛出一个语法错误。

    但是您也需要转义其中的引号。(
    \“pdf.pdf\”路径“
    )但您也需要转义其中的引号。(
    \“pdf.pdf\”路径