检测jquery.tinymce.js

发布于 2024-12-20 14:25:26 字数 1371 浏览 1 评论 0原文

我们有一个“浏览器测试页”,用于诊断用户问题。用户可以填写一些字段,以及相当多的检测。然后可以将该页面中的数据通过电子邮件发送给我们的技术支持。该页面位于 http://www.rephunter.net/test-browser.php 。当前页面不再具有完整功能,原因如下:

我刚刚将网站从使用 dojo 转换为 jquery。测试的一部分包括检查 tinymce 支持。我们曾经运行“常规”tinymce 库,但已切换到 jquery 版本。在使用旧版本 TinyMCE 的先前版本中,通过以下方式测试了支持:

if(typeof tinyMCE == 'undefined')

但是,使用新的 tinymce 实例,即使页面上有一个 tinymce 编辑器,它也始终显示为未定义。我已经做了一些测试,看来tinyMCE仅在提交表单后才定义。例如,下面的代码片段显示了其工作原理:

<head>
<script type="text/javascript">
    alert('head tinymce=' + typeof tinyMCE);
    function Validate()
    {
        alert('validate tinymce=' + typeof tinyMCE);
        if (tinyMCE)
            alert('tinymce is defined');
    }f
</script>
</head>

<body>
form onsubmit='Validate()'>
<textarea class="tinymce"></textarea>
<input type="submit" />
</form>
<script type="text/javascript">
    alert('body tinymce=' + typeof tinyMCE);
</script>

无论我在检测程序中做了什么,获取有效的tinyMCE对象的唯一方法似乎是提交页面。也就是说,“身体”警报不起作用; “验证”警报确实如此。

一种解决方法是在页面上放置说明,让用户查看页面并查看是否有编辑器而不仅仅是文本区域。然而,对于我们的用户来说,这并不理想。我们确实想要电子邮件,因此我需要一种方法来检测tinyMCE。

我也许可以通过一个检测tinymce的onsubmit函数来解决这个问题,但我也想要一些可以在页面第一次显示时直接显示给用户的东西。

有一个简单的解决方案吗?类似于 if(typeof tinyMCE == 'undefined') 的优雅

We have a "browser test page" which is used to diagnose user problems. There are fields the user can fill out, plus quite a few detections as well. The data from that page can then be emailed into our tech support. The page is at http://www.rephunter.net/test-browser.php. The current page is no longer fully functional, for the following reason:

I have just converted the website from using dojo to jquery. Part of the test includes checking for tinymce support. We used to run the "regular" tinymce library, but have switched over to the jquery version. In the previous version, which used an older version of TinyMCE, support was tested by the following:

if(typeof tinyMCE == 'undefined')

However, with the new instance of tinymce, it always comes up as undefined, even if there is a tinymce editor on the page. I have done some testing and it appears that tinyMCE is defined only after the form is submitted. For example, here is a snippet that shows how this works:

<head>
<script type="text/javascript">
    alert('head tinymce=' + typeof tinyMCE);
    function Validate()
    {
        alert('validate tinymce=' + typeof tinyMCE);
        if (tinyMCE)
            alert('tinymce is defined');
    }f
</script>
</head>

<body>
form onsubmit='Validate()'>
<textarea class="tinymce"></textarea>
<input type="submit" />
</form>
<script type="text/javascript">
    alert('body tinymce=' + typeof tinyMCE);
</script>

No matter what I have done in the detection program, the only way to get a valid tinyMCE object seems to be to submit the page. That is, the 'body' alert does not work; the "validate" alert does.

One workaround is to put on the page instructions for the user to look at the page and see if there is an editor rather than just a textarea. However, with our users this would be less than ideal. We really want the email, and thus I need to have a way to detect tinyMCE.

I may be able to work this out by having an onsubmit function that detects tinymce, but I would also like something that can be displayed directly to the user on first display of the page.

Is there a simple solution? Something similar to the elegance of if(typeof tinyMCE == 'undefined')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

救星 2024-12-27 14:25:26

怎么样:

typeof jQuery.fn.tinymce != 'undefined'

我刚刚查看了你的插件的源代码并在一开始就看到了这个:

(function(b){var e,d,a=[],c=window;b.fn.tinymce=function(j)
                                   ^^^^^^^^^^^^

How about this:

typeof jQuery.fn.tinymce != 'undefined'

I just looked at your plugin's source and saw this in the beginning:

(function(b){var e,d,a=[],c=window;b.fn.tinymce=function(j)
                                   ^^^^^^^^^^^^
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文