Chris Pollett > Students >

    ( Print View )


    [Project Blog]

    [CS297 Proposal]


    [Firefox Plugin-PPT]





    [Firefox Plugin to match h1 tags-ZIP]



    [CS298 Report-PDF]



Deliverable 2 -- DOM Test


The second deliverable was to create a test HTML DOM and capture various mouse events such as mouseover and mouseout. A test HTML page was created with various block level elements such as <div>, <p> and <table>.
A test javascript function was called onLoad event of the HTML page. This function registered the mousedown and the mouseup event so that users selection block that includes the start element and the end element is captured. The DOM nodes were then iterated over selecting the parent node till the <body> node was encountered. The path was then alerted to the user. The test was done to determine the uppermost block level element that can be saved. The following listing shows the piece of code that traverses the DOM looking for block level elements and then prompts the user

function calculatePath(tgt) {
	arr = new Array();
	//alert("int tgt " + tgt);
	path=tgt.tagName+" ";
	while(tgt.tagName != 'BODY') {
		path=path+ tgt.parentNode.tagName +" -- ";
		tgt = tgt.parentNode;
	return arr;


function capturePathUp(upNode) {
	var selection;
	if(document.selection) {
		selection = document.selection
	} else {
		selection = window.getSelection();
	//uparr = calculatePath(upNode);
	//alert("path " + startarr.join(' | '));
	/*var lastpop;
	if(downarr.length > uparr.length) {
		for(i = downarr.length; i >= uparr.length; i--) {
			lastpop = downarr.pop();
	} else if(downarr.length < uparr.length){
	} else {