如何使用tinyMCE在Filemaker webviewer中通过javascript解析html

时间:2015-07-26 10:52:23

标签: javascript filemaker

我在Filemaker 14 DB中有一个webviewer,其中包含webviewer的以下代码。



"data:text/html,<!DOCTYPE html>
<html>
<head>
<script type=\"text/javascript\" src=\"http://example.com/js/tinymce/tinymce.min.js\"></script>
    <script type=\"text/javascript\">
        tinymce.init({
            selector: \"#mytextarea\",
skin: \"lightgraynofonts\",
height: 500,
browser_spellcheck : true,
fontsize_formats: \"8pt 10pt 12pt 14pt 18pt 24pt 36pt 48pt\",
font_formats: \"Andale Mono=andale mono,times;\"+
        \"Arial=arial,helvetica,sans-serif;\"+
        \"Arial Black=arial black,avant garde;\"+
        \"Book Antiqua=book antiqua,palatino;\"+
        \"Comic Sans MS=comic sans ms,sans-serif;\"+
        \"Courier New=courier new,courier;\"+
        \"Georgia=georgia,palatino;\"+
        \"Helvetica=helvetica;\"+
        \"Impact=impact,chicago;\"+
        \"Symbol=symbol;\"+
        \"Tahoma=tahoma,arial,helvetica,sans-serif;\"+
        \"Terminal=terminal,monaco;\"+
        \"Times New Roman=times new roman,times;\"+
        \"Trebuchet MS=trebuchet ms,geneva;\"+
        \"Verdana=verdana,geneva;\"+
        \"Webdings=webdings;\"+
        \"Wingdings=wingdings,zapf dingbats\",
 plugins: \"table textcolor hr preview\", 
    tools: \"inserttable\",
    toolbar: \"forecolor backcolor bold italic underline alignleft aligncenter alignright alignjustify formatselect fontselect fontsizeselect cut copy paste bullist numlist outdent indent table preview superscript undo redo removeformat\"

        });
    </script>
</head>
<body>
    <form onsubmit=\"return submitForm()\">
<button type=\"submit\">Save</button>
        <textarea id=\"mytextarea\">"& Product Templates Interface::Description & "</textarea>

    </form>
</body>
<script>
function submitForm() {
var theParam = escape(tinyMCE.activeEditor.getContent());
var theURL = \"fmp://$/" & Get ( FileName ) & "\?script=tiny&param=\" + theParam;
window.location = theURL ;
document.getElementById(\"mytextarea\").value = theParam;
return false;
}
    function show(){
        var data = document.getElementById(\"mytextarea\").value;
        alert(tinyMCE.activeEditor.getContent());
    } </script>
</html>"
&#13;
&#13;
&#13;

有一个名为tiny的脚本,只需拉动参数并设置与上面相同的字段。

现在问题是,如果tinyMCE textarea中的任何代码使用span或div,那么它将具有一组&#34; (引号)。现在这是FM错误的结果,并且没有显示任何结果。所以我需要以某种方式逃避&#34; (引号)首先但是找不到文件制作者允许的解决方案。 javascript函数中的string.replace()不能作为单个转义引号(\&#34;)停止关闭窗口的文件制作者。 任何想法或指针?

1 个答案:

答案 0 :(得分:0)

我最近在FM DevCon 2015上学到的一种方法(但尚未尝试)涉及将HTML内容导出到临时目录并使用file:// URL从那里加载,而不是使用数据URI方法。

这种方法也可以帮助您调试这样的问题,因为您可以在Chrome或Firefox中加载导出的页面并使用更复杂的调试工具。