1

I am trying to load a window when the page is loaded. If I try to open the window using a button the code works.

I iam using:

$(document).ready(function() {
window.open ('http://google.com/', 'newwindow', config='height=720,width=1064, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');
});

However, it is not load the window.

Any suggestion?

$(document).ready(function() {
  window.open('http://google.com/', 'newwindow', config = 'height=720,width=1064, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');
  $('.open_webmail').click(function() {
    window.open('http://google.com/', 'newwindow', config = 'height=720,width=1064, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');
  });
});
.open_webmail {
  background-color: rgba(0, 124, 255, 0.7);
  color: white;
  font-size: 18px;
  cursor: pointer;
  -webkit-transition: all 550ms ease-in-out;
  transition: all 550ms ease-in-out;
  -moz-transition: all 550ms ease-in-out;
  -o-transition: all 550ms ease-in-out;
  -ms-transition: all 550ms ease-in-out;
  display: inline-block;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: 200px;
  height: 100px;
  margin: auto;
}
.open_webmail:hover {
  background-color: rgba(163, 0, 255, 0.7);
  color: #c5c5c5;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<button type="button" class="open_webmail">Login</button>
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
SNos
  • 3,430
  • 5
  • 42
  • 92

1 Answers1

0

You could try $(window).ready() also check your pop-up settings, maybe it's being blocked. Because your code works on js fiddle, I tested it.

  • thanks had pop up blocked. Is there a way to force a window to not be blocked? – SNos Jun 19 '15 at 17:21
  • There may be some hackish way to do it in some specific browser but the general rule is that you can't get around pop-up blockers. I would recommend learning how pop-up blockers work from the behavioral point of view more than the technical and decide if it is necessary for you to force an unwanted pop-up on your users. http://stackoverflow.com/questions/2587677/avoid-browser-pop-up-blockers – Helmut Granda Jun 19 '15 at 17:26