【问题标题】:how to find external links in article in joomla 2.5 plugin如何在 joomla 2.5 插件中的文章中查找外部链接
【发布时间】:2014-10-18 06:19:12
【问题描述】:

我正在 joomla 2.5 中为外部链接创建一个插件

我想查找外部链接并在此之前添加一些文本。

像这些:

http://domain.com/new => redirect.php?url=http://domain.com/new

或:

www.domain.com/new => redirect.php?url=www.domain.com/new

或:

domain.com/new => redirect.php?url=www.domain.com/new

我可以完成所有步骤,但我找不到外部链接。 请帮帮我

【问题讨论】:

  • 您的插件应该在内容加载后运行,您应该在 html 中搜索外部链接。通过使用正则表达式(不推荐)或搜索任何 元素并检查 href 值

标签: plugins joomla hyperlink find


【解决方案1】:

我会这样做的方式是使用 js,您可以将其添加到模板中,而无需使用插件。 js 脚本应该遍历所有“a”DOM 元素并检查 href 是否为外部链接。如果是这样,请修改 href 值。

Fastest way to detect external URLs

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-10
    • 1970-01-01
    • 1970-01-01
    • 2013-08-28
    相关资源
    最近更新 更多