Mootools将文件类型设置为在新窗口中打开
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mootools将文件类型设置为在新窗口中打开相关的知识,希望对你有一定的参考价值。
From: David Walsh.http://davidwalsh.name/dw-content/open-links.php
/* classes */ var OpenLinks = new Class({ //initialization initialize: function(file_extensions,override_targets,target,no_class) { //analyze all anchors $$('a').each(function(el) { //check each href for case-insensitive file extensions var str = el.get('href'); var ext = str.substring(str.lastIndexOf('.') + 1,str.length) if(file_extensions.contains(ext.toLowerCase()) && ((override_targets || !el.get('target')) && !el.hasClass(no_class + ''))) { el.setProperty('target',target ? target : '_blank'); el.setStyle('color','#f00'); } }); } }); /* do it! */ window.addEvent('domready', function() { //enter in as lower case var olinks = new OpenLinks(['doc','pdf','xls','jpg','gif','png'],1,'_blank','no-target');/works //var olinks = new OpenLinks(['doc','pdf','xls','jpg','gif','png'],1,'_blank');//works //var olinks = new OpenLinks(['doc','pdf','xls','jpg','gif','png'],1);//works //var olinks = new OpenLinks(['doc','pdf','xls','jpg','gif','png'],0);//works //var olinks = new OpenLinks(['doc','pdf','xls','jpg','gif','png']);//works });
以上是关于Mootools将文件类型设置为在新窗口中打开的主要内容,如果未能解决你的问题,请参考以下文章