Solved

Window.open() is not working even if i disable pop blocker

Posted on 2008-10-28
5
299 Views
Last Modified: 2012-05-05
Experts,

Is there any reason why this code should not work or be blocked by the pop blocker? Even if i have disabled that thing.
function openReportWindow(strURL) 

{

    try

    {

    

        var top = (window.screen.height - 580) / 2;

        var left = (window.screen.width - 1000) / 2;

        

        oWnd=window.open(strURL,"Echox","location=0,status=0,scrollbars=1,menubar=0,resizable=1,toolbar=0,width=800,height=650");

        

        oWnd.moveTo(top,left); 

        return false; 

        

    }

    catch(err)

    {

       alert(err.message);

    }

}

Open in new window

0
Comment
Question by:dotnetpro
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:Pawel Witkowski
ID: 22822202
I test this code in firebug. Everything is ok in mine browser so I think that there is other problem not related with this script, or you have very restrictive browser setting.

function openReportWindow(strURL) 

{

    try

    {

    

        var top = (window.screen.height - 580) / 2;

        var left = (window.screen.width - 1000) / 2;

        

        oWnd=window.open(strURL,"Echox","location=0,status=0,scrollbars=1,menubar=0,resizable=1,toolbar=0,width=800,height=650");

        

        oWnd.moveTo(top,left); 

        return false; 

        

    }

    catch(err)

    {

       alert(err.message);

    }

}
 

openReportWindow('http://test');

Open in new window

0
 
LVL 7

Expert Comment

by:bluV11t
ID: 22822310
Hi!
Tested the code in IE8 and I get an access denied error at oWnd.moveTo(top,left);

This security issue occurs if you try to access a window where the document (url) is on a different domain.
0
 
LVL 1

Author Comment

by:dotnetpro
ID: 22822446
Do you guys think there is a bettter way or just way to tell the user to allow pop up s from only this site. Any alert message would you think ?
0
 
LVL 7

Accepted Solution

by:
bluV11t earned 250 total points
ID: 22822548
Hi!
Just remove the line oWnd.moveTo(top,left);  and you should be fine :-)
0
 
LVL 18

Expert Comment

by:Pawel Witkowski
ID: 22826720
Better way? do you really need to open new window ? Maybe opeing a div with Iframe will be a solution for you ? ^^ just think about it - users dont like to have new windows open ... :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JavaScript/Java - Changing an image background color 4 56
Reference Error with plugin 1 31
Randomize in Owl Carousel v1.3.2 6 20
wordpress display sub menu only when click 12 23
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now