Results 1 to 4 of 4

Thread: javascript window.open not working in IE

Threaded View

  1. #4
    Hyperactive Member coothead's Avatar
    Join Date
    Oct 2007
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    285

    Re: javascript window.open not working in IE

    Hi there jlbantang,

    bearing in mind that many users have javascript disabled
    or pop up windows blocked, this is how I would code it...
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    
    <title></title>
    
    <script type="text/javascript">
    
    function init(){
    
       mywindow=null; 
       title='Page-Title';
       w=400;
       h=500;
       l=(screen.width-w)/2;
       t=(screen.height-h)/2;
       features='width='+w+',height='+h+',left='+l+',top='+t;
    
    document.getElementById('openpop').onclick=function(){
    if(mywindow) {
       mywindow.close();
     }
       mywindow=window.open(this.href,title,features);
       mywindow.focus();
       return false;
     }
    
    document.getElementById('closepop').onclick=function(){
    if(mywindow) {
       mywindow.close();
       }
      }
     }
    
       window.addEventListener?
       window.addEventListener('load',init,false):
       window.attachEvent('onload',init);
    </script>
    
    </head>
    <body>
    
    <div>
    <a id="openpop" href="supplier.aspx?src=rpt&tar=costcentre">open pop-up window</a>
    <a id="closepop" href="logout.aspx">log out</a>
    </div>
    
    </body>
    </html>
    
    Last edited by coothead; Aug 28th, 2012 at 04:11 AM.


    ~ the original bald headed old fart ~

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width