TinyMce 遇到超链接绝对 url 的问题 [英] TinyMce troubles with hyperlink absolute url

查看:43
本文介绍了TinyMce 遇到超链接绝对 url 的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 textarea 输入表单中添加了 tinyMce 编辑器.不幸的是,我在发送超链接绝对网址时遇到了麻烦.

I added tinyMce editor in my textarea input form. Unfortunately I have troubles sending hyperlink absolute urls.

我在 php CMS 中动态创建页面.

I create dynamically the pages within a php CMS.

我可以启动 tinyMce 并发送格式化文本.当我尝试添加url时,最终结果不是我添加的absoluted url,而是前面是另一个字符串url,如下所示:

I can start tinyMce and I can send formatted text. When I try to add url, the final result is not the absoluted url I added, but it is preceded by another string url, as showed under:

//Input url: www.example.it, will process the following result:
//http://www.myDomain.example/folder/"http://www.example.it"

因为最终链接不起作用,即使在 tinyMce 预览中看起来一切都很好.

Because of that the final link doesn't work, even if in the tinyMce preview all seems to be good.

我按照官网FAQ中的说明设置初始值:

I followed the indications written in the official website FAQ to set the initial values:

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  relative_urls : false,
  remove_script_host : true,
  document_base_url : 'http://www.mydomain.example/folder/'
});

推荐答案

这真是一个令人讨厌的问题.注意到您输入的 url 周围的转义引号了吗?您已将 magic_quotes 设置为开启!我刚刚花了 2 小时再次跟踪这个错误,所以我想我最好在网站上记录它.

This is a really nasty gotcha. Notice the escaped quotes around the url you entered? You have magic_quotes set to on! I've just spent 2 hours tracking this bug down again so I figured I'd better document it on the site.

在将 url 保存到数据库之前添加:

Before saving the url to the database add:

if  (get_magic_quotes_gpc())
    foreach ($row as &$value)
        $value = stripslashes($value);

这将摆脱转义引号并允许浏览器识别绝对网址.

This will get rid of the escaped quotes and allow the browser to recognize an absolute url.

这篇关于TinyMce 遇到超链接绝对 url 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆