views:

122

answers:

1

I know how to center a regular popup window with javascript, but I can't get it to work with CodeIgniter's anchor_popup function.

Here is my code

$attributes = array(
    'class'     =>  'blue-button',
    'width'     =>  '800',
    'height'    =>  '600',  
    'screenx'   =>  '(window.width - 800) / 2',
    'screeny'   =>  '(window.height - 600) / 2'
);

echo anchor_popup('program/start_worksheet/8', 'Start Worksheet', $attributes);
+1  A: 

This works for me:

<?php
$attributes = array(
    'class'     =>  'blue-button',
    'width'     =>  '800',
    'height'    =>  '600',
    'screenx'   =>  '\'+((parseInt(screen.width) - 800)/2)+\'',
    'screeny'   =>  '\'+((parseInt(screen.height) - 600)/2)+\'',
);
echo anchor_popup('program/start_worksheet/8', 'Start Worksheet', $attributes);
?>

Edit: Actually as I look at this now ... this seems to be like a little hack for this function in the url helper but as it works it is ok i think

budinov.com
Hmm, doesn't look like there is a way to do this without hacking things up a little bit.... Thanks for your solution!
Chris Schmitz