Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
How to open browser window in iframe using JavaScript

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();
    }
  });
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!