mootools_使用MooTools 1.2修复锚点URL

mootools

The administrative control panel I build for my customers features FCKEditor, a powerful WYSIWYG editor that allows the customer to add links, bold text, create ordered lists, and so on. I provide training and documentation to the customers but many times they simply forget to include the "http://" when add links into their content. Essentially, they end up with links that look like:

我为客户构建的管理控制面板具有FCKEditor,这是一个功能强大的WYSIWYG编辑器,允许客户添加链接,粗体文本,创建有序列表等。 我为客户提供培训和文档,但是很多时候,他们在将链接添加到他们的内容中时忘记了添加“ http://”。 本质上,它们最终具有如下链接:


	<a href="www.davidwalsh.name">Click here</a>


Obviously, that's a problem. Luckily MooTools 1.2 provides a quick fix for that problem for website users.

显然,这是一个问题。 幸运的是,MooTools 1.2为网站用户提供了针对该问题的快速修复。

MooTools 1.2代码 (The MooTools 1.2 Code)


window.addEvent('domready', function() {
	$('fix-links').addEvent('click', function() {
		$$('a[href^=www.]').each(function(el) {
			el.set('href','http://www.' + el.get('href').split('www.')[1]);
		});
		alert('Links fixed.');
	});
});


The above solutions is NOT the best solution because it doesn't correct what the search engines see. Have a PHP solution? Submit it! The best solution is to fix the link within the FCKEditor plugin at the time the user adds the link. The code above, however, will buy you a little time to go in and fix any existing errant links.

上述解决方案不是最佳解决方案,因为它无法纠正搜索引擎看到的内容。 有PHP解决方案吗? 提交! 最好的解决方案是在用户添加链接时在FCKEditor插件中修复该链接。 但是,上面的代码将使您花费一些时间来修复所有现有的错误链接。

翻译自: https://davidwalsh.name/fix-anchor-urls-mootools

mootools

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值