Outputing a text file for user to see - html

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

Related

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

Make changes to a website written in HTML based on the content on a text file

So I've been looking around for an answer to this, without success.
So I'm looking to have the text inside of a .txt file to be inserted in a line in html5 code, I can't think of how this should be worded so here's an example.
<iframe type="text/html" frameborder="0" width="1920" height="1080" src="https://www.youtube.com/embed/TEXTFILECONTENT" allowfullscreen></iframe>
And is it possible to have it change every time the content of the text file changes?
Any questions please reply I'm sure I wrote this somewhat wrong.
Yes u can!, u must create your HTML5 with Ajax. example:
Client open ur HTML5 page
Client get fresh text
every 3 sec. ajax synchronize your text file from server or other
this can solve your problem because if u change text then each 3 sec. client get uptodate text..
just change src to your file.., replace 'TEXTFILECONTENT' with the file name YOUR.txt
Your IFrame's src should simply be set to the full url to the text file. In your example, replace 'TEXTFILECONTENT' with the file name, like 'MyTextFile.txt'. Then the browser should fetch the file and display it in the iframe. If your textfile is in a subdirectory, then add that to the url, like 'folder/textfile.txt'.
Edit:
You can add a link to your page that loads the textfile into the iframe. First give your iframe an id, like this:
<iframe id="myiframe" type="text/html" frameborder="0" width="1920" height="1080" src="https://www.youtube.com/embed/TEXTFILECONTENT" allowfullscreen></iframe>
Then give your link a target attribute, like this:
Discord server
Now when people click the link the textfile will be loaded into the iframe.

SharePoint Showing a mht file securly

On my sharepoint I can display my excel file in mht file. but when I get to display the aspx page it keeps asking me if I want to display all content.
I know I just need to change the way the sharepoint goes to the source but if I do change it, the file just try's to download. I do not want that. I wanted to display a directory page that has a few mht files. and while I can display it, it keeps displaying a warning saying its only displaying secure content. How should I go about this, I know it needs to be https but how do I go about this ???
<p>
<strong>
<iframe align="middle" src="\\sharepoint.company.com\sites\Display\SitePages\HTML\Type\fileA.mht" width="100%" height="150%" scrolling="no" ></iframe>
</strong>
</p>
What I had to do was post it as a iframe with a separate page. that got rid of the security problem.
<strong>
<iframe align="middle" src="\\sharepoint.company.com\sites\Display\SitePages\HTML\Type\fileA.aspx" width="100%" height="400px" frameBorder="0"></iframe>

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

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.

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.