我正在尝试将自定义图像管理器作为 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/