Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using custom meta box in wordpress post page. this box contains a custom Copy button. Now, I want to open a popup window on clicking 'copy' button. Also I need to show content of parent window in this popup.

share|improve this question
1  
The post edit screen has no parent window. –  toscho Apr 21 '13 at 11:56
    
Please try to make this question more clear. –  s_ha_dum Apr 21 '13 at 15:06
add comment

1 Answer

up vote 0 down vote accepted

Maybe you can open a thickbox with javascript.

A example with check for the height and width of the thickbox.

                    <script type="text/javascript">
                    <!--
                        var viewportwidth,
                            viewportheight;
                        if (typeof window.innerWidth != 'undefined' ) {
                            viewportwidth = window.innerWidth-80,
                            viewportheight = window.innerHeight-100
                        } else if (typeof document.documentElement != 'undefined'
                            && typeof document.documentElement.clientWidth !=
                            'undefined' && document.documentElement.clientWidth != 0)
                        {
                            viewportwidth = document.documentElement.clientWidth,
                            viewportheight = document.documentElement.clientHeight
                        } else { // older versions of IE
                            viewportwidth = document.getElementsByTagName('body' )[0].clientWidth,
                            viewportheight = document.getElementsByTagName('body' )[0].clientHeight
                        }
                        document.write('<a onclick="return false;" href="<?php echo WP_PLUGIN_URL . '/' 
                            . FB_WM_BASEDIR; ?>/index.php?KeepThis=true&amp;TB_iframe=true&amp;height=' 
                            + viewportheight + '&amp;width=' + viewportwidth 
                            + '&amp;modal=false" class="thickbox button"><?php _e( 'Preview', FB_WM_TEXTDOMAIN ); ?></a>' );
                        //-->
                    </script>

Also it is important, that you initialize all requirements, via add_thickbox();. Inside the Thickbox you can load your parent data.

share|improve this answer
    
Thanks bueltge, I'll take a look and get back to you. –  Sumit Apr 22 '13 at 2:53
    
I used the following function to invoke light box on copy button:function my_enqueue($hook) { if( 'post.php' != $hook ) return; wp_enqueue_script( 'my_custom_script', plugins_url('/lightbox-form.js', FILE) ); } add_action( 'admin_enqueue_scripts', 'my_enqueue' ); –  Sumit Apr 22 '13 at 6:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.