Browse Prior Art Database

Parse JavaScript links in HTML

IP.com Disclosure Number: IPCOM000019669D
Original Publication Date: 2003-Sep-24
Included in the Prior Art Database: 2003-Sep-24
Document File: 4 page(s) / 77K

Publishing Venue

IBM

Abstract

Disclosed is a program to parse JavaScript links in Hypertext a Markup Language (HTML) file. The methods included in this program are using Extensible Markup Language (XML) to represent JavaScript link properties and using XML to represent JavaScript parser functions.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 54% of the total text.

Page 1 of 4

Parse JavaScript links in HTML

JavaScript is a lightweight interpreted programming language. Most of JavaScript code is embedded into an HTML, which is tag-based markup language. Unlike HTML, which uses the tags and attributes to define the Uniform Resource Locator (URL) links, the links in JavaScript are stored in the property of each JavaScript object. The different ways to hold the URL links in HTML and in JavaScript create a problem when using a parser or a complier to parse the links in JavaScript embedded in an HTML file. If the parser is using XML tag-based technique it can only recognize tags and parse the corresponding URL links, while the URL links in JavaScript remains unrecognized.

The following example (Figure 1) is an HTML file containing a JavaScript code with an URL link embedded:

<!-- Sample HTML file -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
</TITLE>
<LINK href="file:///D:/studiotemp/d7102appleterror/theme/Master.css"
rel="stylesheet" type="text/css">
<SCRIPT language="JavaScript">

...

buttPic[howto].src = "images/howto.gif";

...

</SCRIPT>
</HEAD>

Figure 1 - HTML File with Embedded JavaScript

If an XML file (parser.xml) is used as a parser configuration file as illustrated in Figure 2, in the HTML example (Figure 1) above, the HTML tag ( <LINK ) and attribute ( href ) are very easy to be transferred to XML tag and attribute:

<tag name="<link"

<attribute name="src"

<attribute name="href"
</tag>

Figure 2 - a Sample XML Parser File

However, since there is no tag or attribute in JavaScript to be directly represented by XML tag, parsing the link in "buttPic[howto].src"in the JavaScript portion will be failed. buttPic{howto} is an array of JavaScript Image objects and src is the property of this object.

1

Page 2 of 4

The following JavaScript Object Properties contain URL links:
* Form.action
* Link.href
* Location.href
* Document.location
* Window.location
* Image.src
* Layer.src
* Document.url

To represent those JavaScript Object Properties in the parser.xml file, creating the XML like tags to symbolize the above JavaScript Object Properties is necessary. The naming convention for these XML tags is described in Figure 3.

.

+

Figure 3 - XML Tag Name Convention for JavaScript Object Properties

In Figure 3, Name of Property means the property name of JavaScript Object Property that contains the URL link. For instance, "action" is a property of Form object and it contains the URL link. Based on this convention, the following special XML tags are made for parsing JavaScript Object Properties,
* .action
* .href
* .location
* .src
* .url

Table 1 shows the relationship between the new JavaScript XML tags and the JavaScript Object Properties:

XML JavaScript Tags JavaScript Object Properties

.action Form.action
.href Link.href, Location.href
.locati...