Result of jquery element creation not as expected in Firefox 14

68 views Asked by At

I'm trying to clear a div and repopulate it with a pdf in html5 with jquery. It works great in Chrome, but Firefox 14 seems to behave oddly. Here's the code:

$("#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));

The three commands that are commented out break Firefox. Without them, the page clears the div, then does the code following what I've shown above. If I put those three commands back in, it doesn't do anything when triggered. Chrome doesn't care, it just works with or without it.

I suppose I have two questions:

  1. How am I supposed to embed a pdf on the fly in Firefox (if I'm doing it incorrectly above)
  2. Do I have a typo I'm not seeing if the above should work? Or is FF bugged?

Thanks!

1

There are 1 answers

1
Ram On

You have missed the quotes:

$(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>");

I don't know how your code works on chrome. It should throw a syntax error.