0

I am trying to use a Coldfusion javascript function to create a cfwindow and center it. I've followed documentation/tutorials to a T and I've tried this in CF8 and CF9 but I can't get it to center. What am I doing wrong?

<a href="javascript:ColdFusion.Window.create('createdWindow','Window Name',
'test.cfm',{modal: true, center: true});">Create Bound Window</a>

Thanks :)

timsayshey
  • 211
  • 1
  • 2
  • 14
  • 2
    Your code looks fine to me. I tested it verbatim and the window centered. Do you have some other CSS that might be interfering? – JhnSctt Feb 18 '11 at 20:10
  • Are there any scroll bars on your page? I have found that the cfdebugging information can throw the window center way out of alignment. Scroll bars may be an indicator of additional code on the page causing misalignment. – davidj Feb 18 '11 at 22:01
  • @JhnSctt I think you were right, I tried the code on a blank page and it worked. I try to my stylesheets to see if they are the culprit. Thanks – timsayshey Feb 18 '11 at 22:08
  • @davidj Scrollbars? Some pages, yes. Though I don't think they are the problem, but you might be on to something with the debugging throwing things off. I will keep an eye on it. Thanks – timsayshey Feb 18 '11 at 22:09

1 Answers1

1

Use the function below to create a CfWindow. Call function create_Window() in <a> tag.

function create_Window() {
    win = name + "_os_" + Math.round(Math.random() * 10000000000);

    try
    {
        twin = ColdFusion.Window.getWindowObject(winname);
        twin.destroy(true);
    }
    catch (e)
    {
        // do nothing because the window does not exist
    }

    ColdFusion.Window.create(
        win,
        'Request Page',
        'windowPageName.cfm?windowname='+win,
        {
            height:600,
            width:700,
            modal:true,
            closable:true,
            draggable:true,
            resizable:true,
            center:true,
            initshow:true
        }
    )

    winname=win;
}
Soumya
  • 13,677
  • 6
  • 34
  • 49
Arasu
  • 132
  • 9