0

I've a jquery ajax call:

var popup = function () {
  if (myurl) {
   $.ajax({
    type: "POST",
    url: myurl,
    data: mydata,
    success: function (response) {  

        // other code here                  
        var x=window.open('', '_blank', 'titlebar=no,scrollbars=yes,menubar=no,height='+height+',width='+width+',resizable=yes,toolbar=no,location=no,location=0,status=no,left='+left+',top='+top+'');
        x.document.open();
        x.focus();
        x.document.writeln(response);
        x.document.close();

        return false;
    },

    error: function () {  
        return false;
    },
  });
 }
}; 

It worked on all browser (on http), but since I use https, the popup window opens and loops without displaying anything and blocks the browser on IE (I tested on ie 8, 9 and 10). On Chrome and Firefox it continues to work.

EDIT

The response which I write on the popup contains jquery/javascript script which cause the issue. But how could I prevent this?

EDIT2

In the jsp (used to create the popup content) I've put

<script type="text/javascript">
<!--
javascript code
// -->
</script>

This resolves in part the issue.

What for the imported js file?

 <script type="text/javascript" src="js/jquery-ui-1.9.1.js"></script>

the path to the jquery file is relative, but the issue still remains. Also if I use external links with https.

If I import js file by using

<!--[if !IE]>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.8.2.min.js"></script> 
<script type="text/javascript" src="https://code.jquery.com/ui/1.9.1/jquery-ui.min.js"></script>
<![endif]-->

all "works" fine, that is IE browser doesn't block when the popup is opened, but I would a solution that allows the script execution

EDIT3

The issue was caused by the ie compatibility mode IE=8 I removed it from the popup page and its parent page and I resolved on IE 10, but what for IE 8 and 9? (without scripts the popup is well displayed on IE)

Sefran2
  • 3,578
  • 13
  • 71
  • 106

2 Answers2

0

f you have add any resource which use another protocol - that would cause an error in IE 8-9.

So you should check if javascript in your new window makes request to https, and all content has https, including images, etc.

Dmitry Zaets
  • 3,289
  • 1
  • 20
  • 33
  • I tried by importing only one extern script i.e. ``, but also in this way it fails (note `https`) – Sefran2 May 17 '14 at 09:39
0

The issue seems to be from extra commma , after error function.

In ajax call, last parameter/attibute to $.ajax call must not be follwed by commma ,.

This works well with all new browsers, but old browsers like IE 7 throws js error on that line & subsequent requests stops.

var popup = function () {
  if (myurl) {
   $.ajax({
    type: "POST",
    url: myurl,
    data: mydata,
    success: function (response) {  

        // other code here                  
        var x=window.open('', '_blank', 'titlebar=no,scrollbars=yes,menubar=no,height='+height+',width='+width+',resizable=yes,toolbar=no,location=no,location=0,status=no,left='+left+',top='+top+'');
        x.document.open();
        x.focus();
        x.document.writeln(response);
        x.document.close();

        return false;
    },

    error: function () {  
        return false;
    }//,   <= Remove this extra comma
  });
 }
}; 

Hope it helps.

Pranav Singh
  • 17,079
  • 30
  • 77
  • 104