I have a VS2019 WinForm app with a form that contains a webbrowser control. The URL for the webbrowser control points to a form on my asp.net web site, HelpForm.aspx. The URL for HelpForm.aspx has args that the aspx page can use in the code file to make a database call with the args supplied to fetch text/html from a SQL Server database then apply that text/html as text to a label on the aspx page. That aspx page is then returned to my webbrowser control on my winForm. That all works fine. This allows me to use the same forms to retrieve different help data from the database.
As part of the text/html stored in the database some of the records contain code to embed a YouTube video. Here is an example of what is in the database:
'... The same is true if you use the mouse wheel while a combo box has the focus.
<object width="560" height="315"><param name="movie" value="https://www.youtube.com/embed/fpXX8mSuDV4"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="https://www.youtube.com/embed/fpXX8mSuDV4" width="560" height="315"></embed></object>
Note: There is a ....'
On some machines this works and the video appears inline with the text but on others I get a black box or a white box with a tiny icon in the upper left corner.
This seems to have something to do with IE/Edge but I cannot find anything useful to help fix this.
Any ideas ?? Thanks
The WebBrowser control is stuck in IE7 mode by default, unless you edit the registry on every computer where your application runs.
But even if you can edit the registry, you'll still be using Internet Explorer. And YouTube dropped all support for Internet Explorer back in March 2020.
Unfortunately, you're going to need to update your application to use a more modern browser control. For example, either CefSharp or WebView2 should work.
Related
I have the code below which is a perfect solution to what I need, which would essentially be embedding any of JPG, GIF, PNG or PDF files in my webpages. It works perfectly in PC browsers, but a critical requirement for the pages is to have them compatible in mobile browsers due to its target users.
<iframe src="uploads/test1.pdf" width="auto" height="auto"> </iframe>
Although image files work fine, PDF files are opened separately in the mobile browser and not embedded inline in the web page. What would be an alternative solution or implementation to this?
You can use PDFJs library. Using just JS you can render pdf files.
Please , check here : https://mozilla.github.io/pdf.js/
One simple option is that the the object element provides a fallback, so you can do:
<object data='some.pdf'>
<p>Oops! Your browser doesn't support PDFs!</p>
<p>Download Instead</p>
</object>
Then, when the mobile browser can't get the item, it'll just show this and you'll be all set, kinda.
Here is my solution to this problem.
<object data="mypdf.pdf" type="application/pdf" frameborder="0" width="100%" height="600px" style="padding: 20px;">
<embed src="https://drive.google.com/file/d/1CRFdbp6uBDE-YKJFaqRm4uy9Z4wgMS7H/preview?usp=sharing" width="100%" height="600px"/>
</object>
Explanation:
<object> tag has a feature that when it is unable to load item, it loads the content inside itself i.e tag.
Since object tag cannot load on mobile view, therefore on mobile devices, embed tag will become active.
Q) Why can't we directly use tag for all cases?
You can actually, but since the embed tag is loading file from
drive, it does not gives any user controls for the pdf that we see
with object tag (zoom, page no., etc.). So our code will give the user pdf view controls atleast in the desktop mode instead of not giving any controls at all.
Q) Direct drive links don't work....so why this solution?
In the above google drive URL, view is changed to preview.
drive.google.com/file/d/1CRFdbp6uBDE-YKJFaqRm4uy9Z4wgMS7H/view?usp=sharing
becomes,
drive.google.com/file/d/1CRFdbp6uBDE-YKJFaqRm4uy9Z4wgMS7H/preview?usp=sharing
So, we can make direct drive links work with this little modification
Google Docs viewer offers a feature, that lets you embed PDF files and PowerPoint presentations on a web page.
<iframe src="https://docs.google.com/viewer?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true" style="width:100%; height:650px;" frameborder="0"></iframe>
replace the URL(http://infolab.stanford.edu/pub/papers/google.pdf) with your own address, It's worked for me but it takes more time to load on
src:http://googlesystem.blogspot.com/2009/09/embeddable-google-document-viewer.html?utm_source=pocket_mylist
The only way I have found, which allows you to embed pdf is using Google drive, then select the menu button once you have opened your file, and select get embed code, you can only use a Google drive or Google docs reference. And you must also turn public sharing on otherwise others won't be able to view it without permission.
Using Adobe PDF Embed API solved my problem.
Adobe PDF Embed API
I ran into the same issue. As a new developer, I wasn't aware that mobile browsers have issues embedding PDF files in iframes. I am now... lol
I racked my resources trying to get this to work when it dawned on me that mobile browsers do not have an issue displaying PNG files in a new window. So, in my infinite wisdom, I opened the PDF files in Gimp 2.0 then exported them as PNG files. And then I created buttons for the user to click and now it opens the graphic instead of trying to embed the PDF.
Looks like this:
<input class="AG" id="UnityBtn" type="button" value="Unity" onclick="location.href='../Meeting_Info/Unity.png'" />
I don't know if this is possible for you, but it worked beautifully for me.
Use an object tag with a iframe tag inside your object tags.
The object data can be a pdf or png file by changing the type and can use any link you want stored wherever, however the I frame is the one which will be loaded for mobiles which has to be a link from Google drive or Google docs you also need to allow the files to be shared public otherwise others won't be able to view them.
I would share the code but this site has some rubbish rules about code and won't let me share them so I'll leave you to Google how object and iframe tags work by viewing better sites that actually wants the help from developers.
Have fun guys!
I currently open a pdf in an iframe. The iframe is hidden and whenever the user hits the button, the iframe loads the pdf source. When the window closes, it removes the source.
The problem that I have is that when a person views the iframe, messes with the zoom and pages, then closes down the iframe, the next person is stuck with the work that the other person was doing. Is there a way I can reset a pdf back to the default zoom, page, orientation, etc?
I've been doing some testing and it seems that adobe has a cache that will cache the settings until the browser closes down. An example is go to
http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf
Mess with the zoom and pages, go to a different web page, and when you go back to that url, you'll see it's the exact same as you left it. I assume that there is a setting that I have to set in adobe reader. I've also tried setting defaults with parameters, but that doesn't seem to be working.
This is for internet explorer 11.
Additional Info
this is for a kiosk system that is running IE11 in Kiosk mode. The shell has been replaced by ie, and it's set to load the site with the hidden iframe. The system is running Adobe Reader X 11.0 and I'm using the following to embed:
<object id="pdf" data="kill-charts.pdf" style="display: none;" width="100%" height="100%" type="application/pdf">
</object>
I've tried embed as well, but it doesn't make a difference. I swapped to object because I wanted to try with parameters. I tried this
<object id="pdf" data="kill-charts.pdf" style="display: none;" width="100%" height="100%" type="application/pdf">
<param name="zoom" value="100" />
</object>
but that didn't work after the second load.
If you look on the last page of the link you provided you will see that you can append #zoom=50 to the URL as follows:
http://example.org/doc.pdf#zoom=50
This will make the browser open it at 50% every time. You can also add other parameters as well such as page number:
http://example.org/doc.pdf#page=1&zoom=50
This method will work at least for the Adobe plug-in, but not guaranteed for other PDF plug-ins.
We allow users of our application to embed a webpage containing a set of thumbnails into another third party webpage/blog etc. The embedding is done by using an object tag.
Each thumbnail provides an option to download original file. When user clicks on this option, the embedded content is disappearing in Safari 5.1.1 and Chrome 15.0 and instead "Could not render embedded content" is shown. Whereas FF 8.0 works correctly i.e. the embedded page stays there even after download, as it should.
The embed code we are using is like this -
<object data="http://myserver.com/em.aspx?e=FytXStk=" height="600" width="900" type="text/html">
<p>Could not render embedded content.</p>
</object>
Can anyone see what might be wrong here? Thanks.
I had to add target="_parent" for the download link. That did the trick.
Actually, if you just choose "Shockwave" instead of "Flash" from the drop down menu for video type, it all works perfectly.
Joomla Core Team has gotta do a better job on notifying developers and webmasters. It's obviously not obvious.
Okay...so apparently with the new update in IE8, it starts up with NO add-ons. Since I cannot program a code to turn on add-ons in a browser, I need to show a message when this occurs. Much like an image has alternative text in the event the image doesn't load...how can I add a message that states:
You are using Internet Explorer 8+ and need to turn on your add-ins like FLASH Player. This site is optimized for Mozilla Firefox or Google Chrome.
ANy suggestions?
Like this:
<object ...>
<param ... />
You are using a browser that does not have Flash player enabled.
Please turn on your Flash player plugin.
</object>
This will display the appropriate message to any visitor (whether they're using IE8 or another browser) if they have Flash disabled.
Alternatively, you could use swfobject.js or similar, which will insert the Flash movie into a <div>. And if Flash is unavailable, the content that is already inside the <div> will be displayed instead.
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