Announcement

Collapse
No announcement yet.

Centre pop-up window?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Centre pop-up window?

    Does anyone know of a way of centring the Extended Info pop-up window on the screen? I found several Javascripts for doing this, and I've tried incorporating the bit that centres the window, but none of them will work in Act_Primary.html - can anyone help?

    TIA

    Malcolm
    ¤ The world wide web needn't cost the earth
    ¤ ARTISAN INTERNET LTD
    ¤ www.artinet.co.uk

    #2
    Hi Malcolm,

    You can use screenX and screenY to specify the window's screen coordinates (the top left is (0,0)).

    Here's how to open a resizable window at (0,0):

    Code:
    window.open("1.htm", "", 
                "left=0,top=0,screenX=0,screenY=0,resizable=1");
    To enable/disable scrollbars, menubar, toolbar, addressbar and statusbar:

    Code:
    window.open("2.htm", "",
                "scrollbars=0,menubar=0,toolbar=0,location=0,status=0");
    Alternatively, we can expand the function by allowing the user to specify a name and the dimensions along with the URL when calling the function. In addition, we can do some calculations to center the pop-up window.

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    function newpop(url, name, w, h) {
      l = (screen.availWidth-10 - w) / 2;
      t = (screen.availHeight-20 - h) / 2;
    
      features = "width="+w+",height="+h+",left="+l+",top="+t;
      features += ",screenX="+l+",screenY="+t;
      features += ",scrollbars=0,resizable=1,location=0";
      features += ",menubar=0,toolbar=0,status=0";
    
      window.open(url, name, features);
    }
    </SCRIPT>
    Now, you can call the function by entering this code in Product Full Description like this:

    Code:
    !!<
    <A HREF="home.html" 
    onClick="newpop('home.html', 'home', 640, 480); return false;"
    TARGET="_blank">HOME!</A>
    >!!
    
    Or
    
    !!< <A HREF="javascript:newpop('home.html', 'Home',640,480)">Home</A> >!!
    Note: The left and top positions of the new window are calculated and stored in variables l and t.

    I hope this helps you.
    Cheers,
    Suresh Babu G

    Comment


      #3
      Thanks for that, Suresh
      ¤ The world wide web needn't cost the earth
      ¤ ARTISAN INTERNET LTD
      ¤ www.artinet.co.uk

      Comment

      Working...
      X