javascript - TinyMCE 4 自定义插件 - 从 iframe 获取值(value)

标签 javascript iframe plugins tinymce

我正在尝试将自定义图像管理器作为 TinyMCE 4 的插件来实现。 我的图像管理器需要位于 iFrame 中(它是一个 PHP 页面)。 这就是我的插件代码的样子。插件代码工作正常。

如何将 iframe 内 PHP 页面的图像路径返回到插件“scr”字段中?

如果有一个实际的例子就太好了(因为我对javascript不太了解)。

tinymce.PluginManager.add('example', function(editor, url) {

    editor.addButton('example', {
        text: 'My button',
        icon: false,
        onclick: function() {


            editor.windowManager.open({
                title: 'Example plugin',
                width: 980,
                height: 800,
                body: [
                    {type: 'textbox', name: 'scr', label: 'URL'},
                    {type: 'textbox', name: 'title', label: 'image-Beschreibung'},
                    {type: 'iframe', name: 'imageframe', url: 'imagedb.php', minWidth: '690', minHeight: '670'}

                ],
                onsubmit: function(e) {
                    editor.insertContent('<img src="' + e.data.scr + '">');
                }
            });
        }
    });
});

最佳答案

一种方法是将 php 变量打印到 html 文档,方法是创建一个将 image_path 作为值的 JavaScript 变量。该值稍后可以在编辑器中使用。

示例:

<?php
 $test1 = '1';

 print '
 <script type="text/javascript">
      var new_var = "<?php print($test1); ?>"
      console.log(new_var);
 </script>';
 ?>

您可能还想查看另一个示例。看看这个帖子:Pass a PHP string to a JavaScript variable (and escape newlines)

关于javascript - TinyMCE 4 自定义插件 - 从 iframe 获取值(value),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21529193/

相关文章:

javascript - 如何在javascript AJAX中从php获取两个id值

javascript - String.toLocaleUpperCase() : Set locale on Node. js

google-maps - 是否可以在 Github 页面站点中嵌入 Google map ?

xml - Win7/64位 : Notepad++ XML Tools Plugin does not load

javascript - HTML + JS - 尝试用 div 包围一些用 for 循环创建的内容

html - HTTPS iframe 显示为 HTTP(混合内容)

iframe - 如何在 Confluence 页面中嵌入 iframe?

javascript - 滚动上的 float 元素

Grails 日历插件

javascript - 为 web 使用 Windows Aero Window Color