The problem is because of the content-type property of the blob. If content-type property of a blob is not set explicitly, Azure Blob storage assigns application/octet-stream.
In your case because you're not setting this property, even for your HTML files, the content type is set as default value i.e. application/octet-stream. Because the browser (especially Chrome) does not understand how to deal with this content type, it downloads it instead of rendering it.
Changing the content type of the blob to text/html should fix the problem.
Videos
I have an iFrame that is displaying some local content. Every time i load the page, it just downloads the content but doesn't display it in the frame.
I have no JS just html and css
I am running it on a chrome browser through the live server extensions in VS Code
HTML -
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
<!-- The sidebar -->
<div class="sidebar">
<p id="cgm-injection">CGM + Injection</p>
<p id="cgm-pump">CGM + Pump</p>
<p id="closed-loop">Closed Loop</p>
<p id="fp-injection">Finger Prick + Injection</p>
<p id="fp-pump">Finger Prick + Pump</p>
</div>
<!-- Main Content -->
<div class="main row" id="container">
<!-- Left event log iframe -->
<div class="left col-5" id="left">
<nav class="tabs">
<button class="tab" id="fullData">Glucose</button>
<button class="tab" id="views">Bolus</button>
<button class="tab" id="json">Basal</button>
</nav>
<iframe src="../static/Output/Closed Loop/Basal.csv" class="data" style="border: 3px solid rgb(69, 94, 110);" height="100%" width="100%" id="leftTable"></iframe>
</div>
<!-- Right data and tabs -->
<div class="right col-7" id="right">
<nav id="eventLogHeader">
<button class="rightTab" id="rightTabs">Event Log</button>
</nav>
<iframe src="../static/Images/concatinated.png" style="border: 3px solid rgb(69, 94, 110);" name="iframe_a" height="100%" width="100%" id="rightData" class="data"></iframe>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
</body>
</html>Hi r/HTML,
I have an HTML page uploaded page to my cloud. I have a shared link to that HTML page which forces one to download said HTML page when opened.
I use this link to embed the HTML page in an iframe (of a second HTML page). Problem is, whenever I open the second HTML page whose iframe is linked to my shared link, it forces a download of the first HTML page. How can ignore the download attribute of the shared link and let the first HTML page be shown in the iframe instead?
because browser understands only html. Change your file extension to .html
or use server side language like php and using file_get_contents() function, you can display text file to browser.
This is the issue with the file. it is not formatted as html. because it has some special unicode (eg) characters at end of file read. if text response has special character like that. it failed to parse response as html embedded in iframe.
you can check this example :
<iframe src='http://humanstxt.org/humans.txt' /> </iframe>
I don't understand why there's brackets around an attribute:
[src]If you don't already know: Don't do that.<iframe>doesn't havetypeas a valid attribute, buttypedoes work for<iframe>'s sister tags<object>and<embed>.
The following Demo does not function on SO due to their restrictive sandbox. Go to this Plunker to see a functional Demo. Source PDF courtesy of PDFObject
It looks like Plunker no longer runs embeded content anymore, so if you want to review a functioning demo, simply copy and paste the entire code in any text editor (Notepad, Notepad++, etc.) and save as an HTML file (.html file extension).
<!DOCTYPE html>
<html>
<head>
<style>
* {
margin: 0;
padding: 0;
}
figure {
display: table;
border: 3px ridge grey;
position: relative;
width: 96vw;
min-height: 250px;
height: auto;
margin: 0 auto 35px;
}
figcaption {
border: 3px ridge grey;
text-align: center;
font: 900 20px/1.5 Verdana;
padding: 0 0 8px 0;
background: rgba(51, 51, 51, 0.3);
color: #fff;
}
iframe,
object,
embed {
overflow: hidden;
position: absolute;
}
</style>
</head>
<body>
<figure>
<figcaption>IFRAME</figcaption>
<iframe src="https://pdfobject.com/pdf/sample-3pp.pdf#page=1" class="frameSet" frameborder="0" allowfullscreen width="100%" height="100%"></iframe>
</figure>
<figure>
<figcaption>OBJECT</figcaption>
<object data="https://pdfobject.com/pdf/sample-3pp.pdf#page=2" class="objectSet" type="application/pdf" width="100%" height="100%"></object>
</figure>
<figure>
<figcaption>EMBED</figcaption>
<embed src="https://pdfobject.com/pdf/sample-3pp.pdf#page=3" class="embedSet" type="application/pdf" width="100%" height="100%">
</figure>
</body>
</html>
You need to modify your URL like the below
iframeURL = 'urlThatYouGetFromAPI' + '&embedded=true'
<iframe [src]="iframeURL"></iframe>
Actually, All you need is adding this string &embedded=true to the end of URL.
Also you can use domSanatizer to make it more safe
readonly #domSanitizer = inject(DomSanitizer);
iframeURL = this.#domSanitizer.bypassSecurityTrustResourceUrl(
`${URL}&embedded=true`
);
