eugene.it
eugene.it

Reputation: 447

Why in google chrome pop up window is shown in different location then in firefox and IE

I hjave a javascript function that opens a new window:

my index.htm page has 3 links:

<body>
    <div class="nav">
        <a href = "javascript:openContent('jobsearch.htm', 875, 1300, 0, 300)">Job Search</a><br />
        <a href = "javascript:openContent('details.htm?page_id=7&details_id=7',875, 1300, 0, 300)">Job Details</a><br />
        <a href = "javascript:openContent('apply.htm?page_id=10&details_id=7', 875, 1300, 0, 300)">Apply</a><br/>
    </div>
</body>

My openContent function:

function openContent(url, width, height, top, left) 
{
   var win;
   win = window.open(url, 'content', "toolbar=no, titlebar=no, status=no, scrollbars=no, resizable=no, top=" + top + ", left=" + left + ", width=" + width + ", height=" + height + "\"");
   win.focus();
}

When clicking the links in index.htm page I open certain page and on firefox and IE, window opens at the same location, but on chrome it opens at the left most location on thr page.

Any ideas?

Thank you

Upvotes: 0

Views: 107

Answers (1)

Benjamin Albert
Benjamin Albert

Reputation: 748

You should try to avoid using native pop up windows as much as possible for the following reasons:

  1. A lot of browsers block them by default.
  2. Each browser presents them differently.
  3. They are generally conceived as annoying.

A good alternativ is jQuery UI Dialog, which gives you more control over how it's presented.

However if you insist on using native pop ups you can try the moveTo function, example:

function example() {
    var win = window.open("http://stackoverflow.com/", 'content', "toolbar=no, titlebar=no, status=no, scrollbars=no, resizable=no, width=500, height=500");
    win.focus();
    win.moveTo(50, 50);
}

It worked for me in the latest versions of Firefox, Chrome, and IE.

Upvotes: 1

Related Questions