How to display .html file in a web page preventing downloading - html

I want to display the myfile.html file in a web page using the iframe tag, but, instead of displaying the contents of the my.html file, the browser downloads the file on the local computer. What should I change in order to make the contents viewables by preventing downloading? I also test both embed and object tag but the result remains the same. The code has as follow:
<iframe src="myfile.html"></iframe>
or
<embed src="myfile.html">
or
<object width="400" height="400" data="myfile.html"></object>
Mention: My intention, of course, is to use just one of the above tags, not all them.

Related

How to embed swf file in floating iframe on website via. bookmarklet?

I am a high schooler & a novice to bookmarklets. I want a bookmarklet that can make a floating iframe on top of a website with a .swf file as it's contents. I've tried many solutions, but a major obstacle is that simply pasting the .swf link as an iframe content ("https://cdn.jsdelivr.net/gh/shirtjs/gstore#v1/cubefield_24.swf". I know, it's stupid.) just downloads the swf file, as we are using moderated chromebooks. Can somebody provide me a bookmarklet code that makes this?
"...But a major obstacle is that simply pasting the .swf URL link as an iframe content just downloads the swf file, as we are using moderated chromebooks."
This has nothing to do with moderators. As a software security issue, Chrome does not accept/load direct links to SWF files unless the link is inside a media tag like <object> or <embed>.
(maybe) solution:
Consider your current <iframe> line...
<iframe src="https://cdn.jsdelivr.net/gh/shirtjs/gstore#v1/cubefield_24.swf"></iframe>
Replace with <embed>code...
<embed src="https://cdn.jsdelivr.net/gh/shirtjs/gstore#v1/cubefield_24.swf" width="550" height="400">

Prevent to download pdf using embed tag

I'm using php, I'm creating a detailed view page of a profile, which has a pdf document, I use the embed tag to display it, but when opened it does not display the pdf file and Automatically download the file. Therefore the user can not see the pdf file displayed.
<embed src="/vh/assets/image/java.pdf" type="application/pdf" width="500" height="500"/>
Is there a way to solve this problem?
PDF documents are not supported as a src in the HTML <embed> tag.
You can get around this issue by using the Google Chrome PDF viewer as the embed `src.
<embed
src="https://drive.google.com/viewerng/viewer?embedded=true&url=http://yourdomain.com/vh/assets/image/java.pdf"
width="500"
height="500"
/>
Note that your url in the src cannot be relative /vh/assets/image/java.pdf, it must be the full url http://yourdomain.com/vh/assets/image/java.pdf.
There also exist some third party libaries such as PDF.JS.
You can refer to w3schools embed tag,It is an html single tag,I can display pdf normally in chrome and firefox.Maybe you can check if your src is correct.
You can try below snippet #toolbar=0 helps disabling the options
<embed id="myObject1" src="file:///C:/Downloads/OoPdfFormExample.pdf#toolbar=0" type="application/pdf" width="1000px" height="600px">
This will disable download, print and other option of pdf viewer on browser

Outputing a text file for user to see

I've been able to use tags to show a pdf file to user this way:
<div>
<object data="/Reports/PDF/#Trim(RptName)#_NewReport.pdf" type="application/pdf" width="860" height="700">
</object>
</div>
Is it also possible to do this for any file other than a pdf file? I need to also show to my users their log file, UserName_Error.log. I tried the following and nothing showed up, the log is there. I googled for tips and could not find it.
<div>
<object data="/Reports/UserError/#Trim(UserName)#_Error.log" type="text/html" width="860" height="700">
</object>
</div>
If this is not possible at all?
Use iframe.
The HTML <iframe> element represents a nested browsing context, effectively embedding another HTML page into the current page.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe

Embedding pdf file in HTML page

How do i embed a pdf file into a HTML document without scrollbars..?
I need to display the whole pages of pdf file in the HTML document.
if the pdf file have 10 pages then the i need to display the whole 10 pages in the HTML document without the scrollbars.
I have tried this code but not worked properly.
<iframe src="/Path to my pdf file#toolbar=0&navpanes=0&scrollbar=1&zoom=133" width="100%" height="100%" scrolling="no"></iframe>
Result of the above code
i got this result but i want to remove the scrollbar and display the full pad in my page.
please help..........

How to check if user is in a specific site within an <object> navigator in your site

I have a webpage with this code:
<object data=http://<?php echo $_GET['wp'];?> width="600" height="400"> <embed src=http://<?php echo $_GET['wp'];?> width="600" height="400"> </embed> Error: Embedded data could not be displayed. </object>
I'd like to know if the user through navigation manages to get to a specific site within the
<object>.
Is that possible?
If not, is there another way to embed a webpage within a website that allows me to know in which webpage he is in?
EDIT: What if we know some of the context of the source code the target page has and we just need to see if the page within the page contains this part of the code, is this possible?
You could use an iframe!
var url =
document.getElementById('my-iframe').src;
Edit: As Ant mentioned, you can't get the url from an iframe tag unless domain of the page in the iframe matches the page containing the iframe.