Pop-up window opens small if security settings are not changed in IE

I am using IE 8 I have the following javascript

<script type="text/javascript">
function popupWindow(url) {
  w = 1026;
  h = 760;
  var left = (screen.width/2)-(w/2);
  var top = (screen.height/2)-(h/2);
  window.location.href="/site/testApps#app=testApp&nav=testNav";
  var newWindow = window.open(url, 'windowname', "toolbar=no, location=no, directories=no,   
  status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width='+w+', height='+h+',   
  top='+top+',left='+left',screenY='+top+', screenX='+left'");
}
</script>

      

the popup opens successfully, but the problem is that it opens in a smaller size. I fixed this by changing the security settings in IE as shown below.

enter image description here

Can anyone shed some light on why this happened? and what is the solution to this problem? with changing security settings in IE?

UPDATE: we have different environments (dev, test and uat (works on secure portlets: //)). this problem only happens if we run https: // it works well (popup opens with appropriate dimensions) in dev and test env.

+3


source to share


5 answers


If there is no need for a new window, I suggest using "internal popups" (for example a large DIV with an iframe inside it). You can let jQuery assign all anchors with a specific class name to open it in an internal popup.

The big advantage is that it is cross-browser, privacy settings are independent and fully stylized.

This also works great against popupkillers as there is no real popup to detect.

Simple example:



$("a.internal-popup").click(function() {
  
  // load href-URL in iframe
  $("#popup-iframe").attr("src", $(this).attr("href"));
  
  // show popup-DIV
  $("#popup-frame").show();
  
  // prevent the original click
  return false;
  
});
      

<a href="site.html" class="internal-popup">Link</a>

<div id="popup-frame">
<iframe src="" id="popup-iframe" name="popup-iframe"></iframe>
</div>
      

Run code


Don't forget to add a close button in the DIV dropdown

See it here: http://jsfiddle.net/PhilQ/ctnqk1Lb/

+2


source


try changing the following

var newWindow = window.open(myURL, 'windowname', "toolbar=no, location=no,
directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes,
copyhistory=no, width='+w+', height='+h+', top='+top+',left='+left',
screenY='+top+', screenX='+left'");

      

to the next, since no variables are used, they instead appear literally as top='+top+'



var newWindow = window.open(myURL, 'windowname', "toolbar=no, location=no,
directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes,
copyhistory=no, width=" + w + ", height=" + h + ", top=" + top + ",
left=" + left + ", screenY=" + top + ", screenX=" + left);

      

also you may notice that the color of the variables is returned and does not blush to indicate text like the original.

+1


source


Use this code for popup to open

jQuery(".Popup").dialog({
    autoOpen: false,
    height: 385, width: 580,
    minheight: 165, minwidth: 460,
    modal: false,
    buttons: {
        "Close": function () {
            jQuery(this).dialog("close");
        }
    }
});

      

and call this function jQuery

:

jQuery(".Popup").dialog("open")

      

+1


source


The cause of the problem is that the "Allow script -opened windows without size or position restrictions" setting is disabled by default in IE8.

Go to Internet Options | Security Tab | Internet - Click the Custom button, then go to the Miscellaneous section. See "Allow script -opened windows without size or position restrictions". If this is disabled, any link that calls a JavaScript function that opens a new window will not be able to resize or reposition the popup.

Change this setting to Enable and the window will resize and position correctly.

+1


source


Implicit globals

your w and h variables are set as global. change them to lines:

var w = 1026;
var h = 760;

      

Operating procedure

Your code sets window.location.href

before calling newWindow = window.open()

, depending on your particular win / ie environment, after setting location.href may have unpredictable results. instead

var newWindow = window.open(...);
window.location.href = "...";

      

String concatenation problem:

In the third argument to window.open, you ran the double quoted string and then sent it using single quotes. Use CRLF on the current line instead:

window.open('about:blank', 'windowname', 'toolbar=no, location=no, directories=no,
    status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, 
    width='+ w +', height='+ h +', top='+ top +',left='+ left +',
    screenY='+ top +', screenX='+ left
);

      

IE Security

Because pop-ups were (and still are) so widespread, IE may ignore some of the window options when used window.open()

.

0


source







All Articles