日期:2014-05-16 浏览次数:20349 次
<script type="text/javascript" src="${appPath}/js/test.js?skin=red"></script>
var _thisScript, _path, _skin; // load path,解析出当前js的访问路径:http://xxxx.../${appPath}/js。 _path = (function (script, i, me) { for (i in script) { if (script[i].src && script[i].src.indexOf('apsa_validate') !== -1) { me = script[i]; } } _thisScript = me || script[script.length - 1]; me = _thisScript.src.replace(/\\/g, '/'); return me.lastIndexOf('/') < 0 ? '.' : me.substring(0, me.lastIndexOf('/')); }(document.getElementsByTagName('script'))); // load js,引入验证插件的js文件 。 document.write(' <script language="javascript" src="'+ _path + '/jquery.bvalidator.js' + '" > <\/script>'); // load css,引入验证插件的css文件 。 _skin = _thisScript.src.split('skin=')[1]; if (_skin) { var link = document.createElement('link'); link.rel = 'stylesheet'; link.href = _path + '/themes/' + _skin + '.css?'; _thisScript.parentNode.insertBefore(link, _thisScript); }