0

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.

  • 1
    The post edit screen has no parent window. – fuxia Apr 21 '13 at 11:56
  • Please try to make this question more clear. – s_ha_dum Apr 21 '13 at 15:06
0

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.

| improve this answer | |
  • 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' ); – Xing Lee Apr 22 '13 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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