I want to open a application within iframe. I am using below script to do it. But, I am not able to open it within iframe.
Can someone help me to figure out how to open it in in iframe.
I have tried searching for the solution but could not find.
I have provided the complete JavaScript code in here.
I tried following code.
@{
string Url = ViewBag.Url;
string Token = ViewBag.Token;
string Response = ViewBag.Response;
}
<br />
<div id='signal'>
<center><img src="~/images/gears.gif" /></center>
</div>
<iframe src="@Url"></iframe>
<div id="output"></div>
<div id="divBackground"></div>
JavaScript
$(document).ready(function() {
$.ajax({
url: '@Url'.replace(/amp;/g, ''),
type: 'GET',
beforeSend: function(xhr) {
xhr.setRequestHeader('Authorization', 'Bearer ' + '@Token');
},
success: function(data) {
var params = [
'height=' + screen.height,
'width=' + screen.width
].join(',');
var popUp;
function showModal() {
const iframe = document.createElement('iframe');
iframe.src = '@Url';
document.body.appendChild(iframe);
//popUp = window.open("", "_blank", params);
popUp.location.href = data.message;
popUp.focus();
LoadModal();
}
function LoadModal() {
var bkg = document.getElementById("divBackground");
bkg.style.display = "block";
}
function OnUnload() {
if (false == popUp.closed) {
popUp.close();
}
}
window.onunload = OnUnload;
showModal();
},
statusCode: {
400: function() {
alert("server returned a bad request response.");
}
},
complete: function() {
$("#signal").hide();
}
});
});