Embed XML in HTML (for Mozilla Nightly) - html

I've seen that there is another post with a similar name, but it doesn't help me.
I use this:
<embed src="../xml/menu.xml" />
to embed some XML content in a div from an HTML file. It is working (the content is displayed) in Google Chrome and Internet Explorer, but not in Mozilla Nightly.
Do you know how to make it work even for Nightly?

Use <object> instead. Per spec, <embed> will only show content handled via plug-ins and SVG, not random document types like XML.

Related

HTML embedded PDF iframe

I have used the tag to embed a pdf file.
<iframe id="iframepdf" src="files/example.pdf"></iframe>
This works fine in Chrome, IE8+, Firefox etc, but for some reason, when some people are viewing it in IE8, the files are downloading instead of embedding. I know this browser is outdated but it is the standard browser within my office and as such, the website has to be designed for this.
Does anyone have any ideas on why this is happening, how I can fix it or else put an error message instead of letting the files download?
It's downloaded probably because there is not Adobe Reader plug-in installed. In this case, IE (it doesn't matter which version) doesn't know how to render it, and it'll simply download the file (Chrome, for example, has its own embedded PDF renderer).
If you want to try to detect PDF support you could:
!!navigator.mimeTypes["application/pdf"]?.enabledPlugin (now deprecated, possibly supported only in some browsers).
navigator.pdfViewerEnabled (live standard, it might change and it's not currently widely supported).
2021: nowadays the original answer is definitely outdated. Unless you need to support relatively old browsers then you should simply use <object> (eventually with a fallback) and leave it at that.
That said. <iframe> is not best way to display a PDF (do not forget compatibility with mobile browsers, for example Safari). Some browsers will always open that file inside an external application (or in another browser window). Best and most compatible way I found is a little bit tricky but works on all browsers I tried (even pretty outdated):
Keep your <iframe> but do not display a PDF inside it, it'll be filled with an HTML page that consists of an <object> tag. Create an HTML wrapping page for your PDF, it should look like this:
<html>
<body>
<object data="your_url_to_pdf" type="application/pdf">
<div>No online PDF viewer installed</div>
</object>
</body>
</html>
Of course, you still need the appropriate plug-in installed in the browser. Also, look at this post if you need to support Safari on mobile devices.
Why an HTML page? So you can provide a fallback if PDF viewer isn't supported. Internal viewer, plain HTML error messages/options, and so on...
It's tricky to check PDF support so that you may provide an alternate viewer for your customers, take a look at PDF.JS project; it's pretty good but rendering quality - for desktop browsers - isn't as good as a native PDF renderer (I didn't see any difference in mobile browsers because of screen size, I suppose).
If the browser has a pdf plugin installed it executes the object, if not it uses Google's PDF Viewer to display it as plain HTML:
<object data="your_url_to_pdf" type="application/pdf">
<iframe src="https://docs.google.com/viewer?url=your_url_to_pdf&embedded=true"></iframe>
</object>
Iframe
<iframe id="fred" style="border:1px solid #666CCC" title="PDF in an i-Frame" src="PDFData.pdf" frameborder="1" scrolling="auto" height="1100" width="850" ></iframe>
Object
<object data="your_url_to_pdf" type="application/pdf">
<embed src="your_url_to_pdf" type="application/pdf" />
</object>
Try this out.
<iframe src="https://docs.google.com/viewerng/viewer?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true" frameborder="0" height="100%" width="100%">
</iframe>
Use Adobe Embed PDF API. This is the solution i used in the end, Works perfectly.

Firefox tells user they need a plugin to display an embedded webpage

There's a section on my site where I display data from another site, using:
<embed src="URL"></embed>
I recently discovered that this works fine for most people, but that Firefox users get an error telling them they need to install a plugin. I searched around for a solution and people seemed to find that specifying the MIME type worked:
<embed type="text/html" src="URL"></embed>
But this isn't working. I can switch to iFrames, but I dislike how they display the information. Any other suggestions?
Per spec, embed elements are only handled via plug-ins or an SVG renderer (and in the latter case behave just like iframe).
You can do <object data="URL"></object>, but of course that will also behave like iframe...
I've been having the same issue with an html5 game. It appears that Firefox doesn't support if you want to embed an external html file. This tag should only be used for plugins.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed
To embed an external html file into another page in Firefox you have to use iframe or object tags instead. For the interactive nature of my external page I used iframe and it worked in IE / Chrome and FF, I had to make the margins larger than the game itself.

iframe alternative to HTML5 for pdf view

I want to display pdf file view in a division on a webpage for reading. I was using iframe for that. But as i searched about it. iframe is deprecated in html5.
Any other compatible(non flash and if possible not html5) way to show pdf content on webpage just like a pdf displayed with an iframe?
The <iframe> is not deprecated at all. At least, the current HTML5 spec draft on <iframe> doesn't say anything about deprecation. In the future please read the specification itself before making ungrounded assumptions.
There's however an alternative to the <iframe> which allows graceful degradation: the <object> tag which in the below example gracefully degrades to a link when the specified content type is not supported by the browser nor any of its plugins (you know, displaying a PDF file inline requires the Acrobat Reader plugin).
<object data="/url/to/file.pdf" type="application/pdf" width="500" height="300">
Download file.pdf
</object>
This is a perfectly acceptable use of an iframe. It has not been deprecated in HTML5, it even has three new tags (sandbox, seamless, and srcdoc). Or you can use <object> as the other answer suggests.

Show SVG files on Sharepoint 2007

I'm building a WSS site which has to show SVG files stored on WSS.
I'm trying to use <object> tag to show it and it doesn't show, however, if I use <embed> it works ok. Im'using IE8 and IE7
I've been reading and everyone tells IE prefers <Object> over <embed>, but in WSS it doesn't work this way.
To display the file I'm using a web content editor webpart with this code:
<object type="image/svg+xml" data="/samples/sample.svg"
name="owMain" width="400" height="150">
</object>
Any clue??
I've found that it's not actually necessary to embed SVG as an object.
If you use the SVGWeb JavaScript library, you can actually put your SVG into a normal Content Editor Web Part via the Source Editor, and manipulate the SVG elements via JavaScript.
The library can also work with a referenced SVG file as an object, but I haven't tried that option.
The library is hosted on code.google.com
You cannot add object tags to the html content of a page in WSS. The issue is that the object tag can be used in lots of very bad ways, so it is stripped out by the underlying engine.
You have found that the content editor webpart does not suffer from the same limitations.
The first step, if you haven't already, is to confirm that the HTML content in the response is as you expect (e.g. view source). If it isn't then you've found your issue. If it is, the next step might be to use a debugging proxy like Fiddler to confirm that all of the related requests are being made and handled as you expect. If they're not then you've found your issue (e.g. security). If they are then by the process of elimination you can safely conclude that either the markup or the browser is lacking.
Is it me or IE does not support SVG? Well, it kinda does but it is tricky and it's to draw, not to show svg files. ... If you open with FF can you see what you are expecting?
added
I made an svg draw in IE ... it's not the same, I know, but it's something that you can read and test: stackoverflow.com/questions/536676
I managed to do this on IE7/8 with the following Html:
<embed width="600" height="450" id="objMapView" src="http://XXXXXXXX/file.svgz"
type="image/svg+xml" name="objMapView" border="1"/>
It works Ok bur requires adobe's SVG Plugin

Firefox 3.0.7 is crashing when embedding a PDF using the object tag

I'm attempting to embed a PDF file into a HTML page using the object tag. The following HTML crashes Firefox 3.0.7:
<object id="pdfObject40" type="application/pdf" data="/file.ashx?id=40" width="432" height="600">
<param name="src" value="/file.ashx?id=40" />
</object>
I don't have a problem in Internet Explorer.
Check the MIME-type the ‘file.ashx’ script is returning. If it's something other than application/pdf, or Content-Disposition is getting sent, there might be wrinkles.
Otherwise, it can only be (a) something odd in the document — do other documents load OK? — or (b) your setup.
In any case I would personally avoid ever embedding a PDF in a web page. A PDF plugin is a pretty inconvenient way to view a document, and the Adobe Reader plugin in particular is both historically awfully unreliable in IE, and also an ongoing security disaster. I'm advising all my clients to uninstall it ASAP.
I ended up using that code for IE and failing over to a link with a about:blank in Firefox. If any has a solution, feel free to add. I'll accept it down the road.
Incase anyone else has this problem, I ended up using object element tag with Firefox and embed element tag with everything else.
I think if I'd not been serving the PDF through an .ashx I could have used the embed tag for everything.
See: http://blogs.adobe.com/pdfdevjunkie/2007/08/using_the_html_embed_tag_to_di.html