Tag Archives: JavaScript

Syntax Highlighter

Well after looking at one of the blog site, I also got interested in integrating some code syntax highlighter plugin for this blog site. After looking around a bit, I came across with “SyntaxHighlighter“. This plugin is based on the Javascript package built by “Alex Gorbatchev“.

SyntaxHighlighter is currently used by Apache, Aptana, Mozilla, Yahoo, WordPress, Bug Labs, Freshbooks and others.

Here is a sample output of it:

using System;
public class HelloWorld
{
    public static void Main(string[] args) {
	Console.Write("Hello World!");
    }
}
Enhanced by Zemanta

Wrap continuous string or text in javascript

Many times it is required to split a long continuous string or text basis of the width of the element in pixels. I had found a good solution on web and redesigned it to make it generic and cross-browser compatible.

You just require to call this javascript function

wrapText ( text , lengthInPixels , splitter ) 

Following is the usage of the function

 <html>
<script language=”javascript” src=”wrapText.js”></script>
<body>
<input id=”txt” size=”150″ /><input type=”button” onclick=”document.getElementById(‘lbl’).innerHTML=wrapText ( document.getElementById(‘txt’).value , 200 , ‘<br/>’ );” value=”Wrap Text” />

<div id=”lbl”></div>
</body>
</html>

  [download id=”4″]

Enjoi!

Reblog this post [with Zemanta]