日期:2014-05-16  浏览次数:20403 次

[JavaScript] How to use HightLight in Dojo?

The HightLight can help make the code blocks in the HTML more beautifully. This recipe tells you how to use this cool feature in the Dojo toolkit.

<!DOCTYPE HTML>
<html>
	<head>
		<title>Dojo Trip</title>
		<link rel="stylesheet" href="http://yandex.st/dojo/1.9.1/dojox/highlight/resources/highlight.css" />
	</head>
	<body>
		<div id="main">
			<div id="code" class="javascript">
				var name = "Dojo";			
			</div>
		
		</div>
		
		<script type="text/javascript">
			var dojoConfig = {async: false};
		</script>
		<script src="http://yandex.st/dojo/1.9.1/dojo/dojo.js"></script>
		<script type="text/javascript">
			require(["dojox/highlight/_base",'dojo/ready',"dojox/highlight/widget/Code","dojox/highlight/languages/javascript"],function(highlight,ready,Code){
				ready(function(){
					new highlight.Code({},"code");
					//var code = new Code({},'code');
					//code.startup();				
				});			
			});			
		</script>
	</body>
</html>