1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<!-- Load jQuery and autolink-js -->
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'></script>
<script src='../autolink.js'></script>
</head>
<body>
<ul>
<li>Our first item contains no links.</li>
<li>Our second item contains a link to Google http://google.com.</li>
<li class='new_window'>Our third item contains a link that opens in a new window http://google.com</li>
<li>Our fourth item contains a link to Google http://google.com and a shortened bitly http://bit.ly/1337</li>
<li class='callback'>Our fifth item contains a link to image https://www.google.com/images/srpr/logo3w.png</li>
</ul>
<script type='text/javascript'>
//<![CDATA[
$(document).ready(function() {
$('li:not([class!=""])').each(function() {
var that = $(this);
var text = that.html();
that.html(text.autoLink());
});
var callback = $('li.callback');
$(callback).html(
callback.html().autoLink({ callback: function(url){
return /\.(gif|png|jpe?g)$/i.test(url) ? '<img src="' + url + '">' : null;
}})
);
var new_window = $('li.new_window');
$(new_window).html(
new_window.html().autoLink({ target: "_blank" })
);
});
//]]>
</script>
</body>
</html>
|