Recent Notes

Displaying keyword search results 1 - 10
Created by James on May 19, 2011 16:02:40    Last update: May 19, 2011 16:05:05
Finally, MathJax makes showing math equations in the browser a reality! Here are some simple demos. A simple example: <!doctype html> <html> <head> <title>Math... Add HTML styling for Firefox: <!doctype html> <html> <head> <title>Math...
Created by Dr. Xi on April 26, 2007 23:00:25    Last update: January 10, 2011 22:15:32
If you ever wonder how those "cool" dialog boxes are made, copy and paste the following code to a file and test it with your browser. This is probably the simplest code for such effects. If you don't know what I mean, try it anyway. <html> <head> <title>Test Overlay</ti...
Created by James on October 15, 2010 20:10:26    Last update: October 15, 2010 20:10:26
Download the Cufon Javascript and save it as cufon-yui.js . Generate the font JavaScript and save it as myfont.js (upload the font file through http://cufon.shoqolate.com/generate/ ). Add these lines to the header element: <script type="text/javascript" src="cufon-yui.js">... Replace selected elements with JavaScript like this: <script type="text/javascript"> Cufon.rep... Full HTML page: <!DOCTYPE html> <html> <head> <title>C... Reference: Cufonize Your Pages – How to add Cufon to your Web Design
Created by Fang on March 23, 2010 03:50:11    Last update: August 18, 2010 21:59:52
This is a simple web application with a single servlet and a single JSP page. It is intended to be a test bed for JSTL tags. You may want to store all syntax, rules, and exceptions in your head, but in my opinion nothing beats a simple test program that allows you play with it all you want. So here it is (build with Maven ). Prerequisites: Maven: http://maven.apache.org/ . You don't need any prior knowledge of Maven, but you need to install the binary. JBoss: http://jboss.org/jbossas/downloads/ , or Tomcat: http://tomcat.apache.org/ if you don't run the SQL tests. You need to know how to deploy a web application (shh! Don't tell your boss it's just copying a file to the deployment folder). Steps: The directory...
Created by Fang on April 01, 2010 22:24:58    Last update: April 02, 2010 02:49:38
In this note I'll show you how to create and package a JSP custom tag. The purpose of this tag is to display a random splash image for a home page, among a set of images. We should be able to add or delete candidate splash images from the WAR archive without the need to change the JSP. This is the intended use of the tag: <%@ taglib uri="http://custom.tag.com/demo" prefix... In the above example you provide a set of images named splash*.png (e.g., splash1.png, spalsh2.png, ...), and the tag will pick a random one to display when the JSP is rendered. Let's get started. I'll use Maven for this purpose. Create the standard Maven directory structure ./pom.xml ./src ./src/main ./src/main/jav... pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0"... SplashTag.java package tagdemo; import java.util.ArrayList......
Created by Dr. Xi on September 01, 2008 02:19:31    Last update: May 23, 2009 16:50:10
Use this bookmarklet to set or delete cookies in a web page. If you leave the expires date as is, the cookie will be deleted. Add this link to your bookmarks to install the bookmarklet. <html> <body> <a href="javascript:if (!windo...
Created by Dr. Xi on August 28, 2008 22:52:01    Last update: March 28, 2009 16:50:42
As a web developer, a lot of times I need to see the cookies in a page (and copy the value to another test program, sometimes). This is a bookmarklet to display the cookies. You may directly add this link to your bookmarks and name it "show cookies". It doesn't work in IE6 because of the JavaScript length limitations . However, you may try putting the script on a web server and importing it to the bookmarklet. <html> <body> <a href="javascript: i...
Created by Dr. Xi on September 17, 2008 02:56:09    Last update: September 23, 2008 02:46:03
When a page is in a standalone window, window.focus() brings that page to the front. With tabbed browsing (in either IE, or Firefox), a popup window may be opened in a new tab. In that case, window.focus() has no effect. For testing purposes, this is the parent page: <html> <body> <script language="JavaScript"... and the popup page: <html> <body> <h2>The Popup</h2> </body>... I haven't found a solution to this when the popup is displayed in a tab. However, you can configure the browser so that it displays popups in a new window instead of a new tab. For IE, open up " Internet Options ", on the general tab under the " Tabs " section, click " Settings ". Under "When a popup is encountered", check...
Created by Dr. Xi on September 22, 2008 23:15:03    Last update: September 23, 2008 02:33:14
Simply put, you can't. There are various hacks to get what you want, but none of them is 100% satisfactory: Disable caching: <html> <head> <meta http-equiv="Expires" C... Open the target URL in a new browser without the toolbar and close the parent: <script language="JavaScript"> <!-- popup=wi... Move forward when back button is clicked. Put this in your web page: <script language="JavaScript"> <!-- javasc... Replace the current location: <a href="#" onclick="location.replace('nextpage.ht... Maybe a better question to ask is why you want to disable the back button. A lot of users use the back button because it is convenient and they are used to it. It's probably better to solve the problem at the server side so that using the back button would not interfere with your...
Created by Dr. Xi on December 12, 2007 20:30:01    Last update: December 12, 2007 20:32:23
This is a script to tail a log file through the web browser. It uses AJAX, apache web server, mod_python, UNIX utilities tail (requires the --lines switch) and wc . The log file may reside on the web server or any other host accessible from the web server through SSH. Although it's written in python, it should be easy to port to other languages such as Perl. Apache httpd.conf : LoadModule python_module modules/mod_python.so ... Python script: import time, os from os.path import basename ...