Results 1 to 4 of 4

Thread: javascript window.open not working in IE

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    617

    javascript window.open not working in IE

    Hi, Im using a custom function to open window most of the time it works in IE,FF and CHROME but when I pass the value

    Code:
    onclick="popupwindow01('supplier.aspx?src=rpt&tar=costcentre','Page Title',400,500);"
    in IE debugger local window it shows

    HTML Code:
    url 
    value="supplier.aspx?src=rpt&tar=costcentre"
    type=String
    
    title
    value="Page Title"
    
    w=400
    h=500
    Code:
    function popupwindow01(url, title, w, h) {
      var left = (screen.width/2)-(w/2);
      var top = (screen.height/3)-(h/2);  
       window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left).focus();
    }
    Thanks in advance.
    Learn something new every .001 second.

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

    Re: javascript window.open not working in IE

    Hi there jlbantang,

    IE requires that there are no spaces in the "Window Name".

    So use one of these three options...
    1. PageTitle
    2. Page-Title
    3. Page_Title


    ~ the original bald headed old fart ~

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    617

    Re: javascript window.open not working in IE

    Thanks works like a charm. Since all webpage are declared is there also a way to close all popup window when user logout from main page.

    Something like these
    Code:
    function closeall_hwnd(){
    
    if (false == ndelivery.closed){
        ndelivery.close();
    }
    
    }
    HTML
    Code:
    <a href="logout.aspx" onclick="closeall_hwnd();"> Logout </a>
    but with no result.
    Learn something new every .001 second.

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

    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