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:
- How am I supposed to embed a pdf on the fly in Firefox (if I'm doing it incorrectly above)
- Do I have a typo I'm not seeing if the above should work? Or is FF bugged?
Thanks!
You have missed the quotes:
I don't know how your code works on chrome. It should throw a syntax error.