Click here to Skip to main content
11,573,322 members (49,911 online)
Rate this: bad
good
Please Sign up or sign in to vote.
Hi
i have write following type of code for open new window using javascript

printURL= "abcd.aspx";
ClientScript.RegisterStartupScript(this.GetType(), "newWindow", "<script>window.open('" + printURL + "', '', 'top=100,left=300,menubar=no,toolbar=no,location=no,resizable=no,height=600,width=850,status=no,scrollbars=yes,maximize=null,resizable=0,titlebar=no');</script>");


its working fine, its open when i am clicking on "window open button". but when i minimize the window and again click on "window open button" new window open in other window, i want to open new window on same window, please suggest me.

waiting for reply.
Posted 24-Jul-12 4:03am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The answer is - You cannot...

This is because your parent page does not know about the new window opened on your previous click. There is no connection between these parent and child instances of the browser windows. So each time you click the link it will create a new instance of browser and as a result a new window everytime.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Check this out:
<html>
<head>
<script type="text/javascript">
var theWin = null;
function open_win(url)
{
    if(theWin && theWin.location)
        theWin.location.href=url;
    else
        theWin = window.open(url,"TheWin",'top=100,left=300,menubar=no,toolbar=no,location=no,resizable=no,height=600,width=850,status=no,scrollbars=yes,maximize=null,resizable=0,titlebar=no');
    theWin.focus();
}
</script>
</head>
<body>
 
<a href="#" onclick="open_win('http://google.com')" />google</a>
<a href="#" onclick="open_win('http://yahoo.com')" />yahoo</a>
 
</body>
</html>

Note: with IE has some limitations (see: http://msdn.microsoft.com/en-us/library/ie/ms536651(v=vs.85).aspx[^])
  Permalink  
v2
Comments
omprakash katre at 25-Jul-12 1:41am
   
Thanks for reply.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

i have got the solution

function openWindow(printURL) {
             var newWin = window.open(printURL, 'PrintABC', 'top=100,left=300,menubar=no,toolbar=no,location=no,resizable=no,height=600,width=850,status=no,scrollbars=yes,maximize=null,resizable=0,titlebar=no');
             if (newWin != null) {
                 newWin.focus();
                 void (0);
             }
          }
  Permalink  
Comments
Zoltán Zörgő at 25-Jul-12 7:01am
   
I think I posted the solution hours before you did. :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


Advertise | Privacy | Mobile
Web03 | 2.8.150624.2 | Last Updated 25 Jul 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100