Truncate paragraph first 100 character and hide rest content of paragraph to show/hide rest contenct with more/less link

Fiddle: http://jsfiddle.net/iambriansreed/bjdSF/ jQuery: jQuery(function(){ var minimized_elements = $(‘p.minimize’); var minimize_character_count = 100; minimized_elements.each(function(){ var t = $(this).text(); if(t.length < minimize_character_count ) return; $(this).html( t.slice(0,minimize_character_count )+'<span>… </span><a href=”#” class=”more”>More</a>’+ ‘<span style=”display:none;”>’+ t.slice(minimize_character_count ,t.length)+’ <a href=”#” class=”less”>Less</a></span>’ ); }); $(‘a.more’, minimized_elements).click(function(event){ event.preventDefault(); $(this).hide().prev().hide(); $(this).next().show(); }); $(‘a.less’, minimized_elements).click(function(event){ event.preventDefault(); $(this).parent().hide().prev().show().prev().show(); }); });​

Library to query HTML with XPath in Java?

There are several different approaches to this documented on the Web: Using HtmlCleaner HtmlCleaner / Java DOM parser – Using XPath Contains against HTML in Java (This is the way I recommend) HtmlCleaner itself has a built in utility supporting XPath – See the javadocs http://htmlcleaner.sourceforge.net/doc/org/htmlcleaner/XPather.html or this example http://thinkandroid.wordpress.com/2010/01/05/using-xpath-and-html-cleaner-to-parse-html-xml/ Using Jericho Jericho and Jaxen … Read more

innerHTML removes attribute quotes in Internet Explorer

IE innerHTML is very annoying indeed. I wrote this function for it, which may be helpfull? It quotes attributes and sets tagnames to lowercase. By the way, to make it even more annoying, IE’s innerHTML doesn’t remove quotes from non standard attributes. Edit based on comments The function now processes more characters in attribute values … Read more

Detect version of Java using JavaScript

According to the fact that we’re finding this page with google, just to help the next guys finding this. Is Java installed? navigator.javaEnabled() http://www.w3schools.com/jsref/met_nav_javaenabled.asp Which version of Java is installed? <script src=”http://www.java.com/js/deployJava.js”></script> <script> var versions = deployJava.getJREs(); </script> http://java.sun.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html#deplToolkit It’s the best way I found to find the version of Java with JavaScript, but use … Read more