Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component


Index of Chilkat Blog Posts

November 2, 2007

MHT Javascript Limitation

This post describes a limitation of Chilkat MHT that users should understand.

Examine this HTML w/ Javascript. An explanation follows:

<html>
<body>
	
<div id='t1'>
This is a test<br />
This is a test<br />
This is a test<br />
This is a test<br />
</div>
	
<script type="text/javascript">
	
function xyz(mode){
	
	if(mode == 'big'){
		x = document.getElementById('t1');
		x.style.backgroundImage = 'URL(img/big.gif)';
	}
	else {
		urlDir = 'img/';
		gifFile = 'dude.gif';
	
		x = document.getElementById('t1');
		x.style.backgroundImage = 'URL(' + urlDir + gifFile + ')';
	}
}
	
xyz('dude');
	
</script>
	
</body>
</html>

The Chilkat MHT component does not run the Javascript. The MHT component works by statically parsing the HTML to find the page elements (images, style sheets, etc.). Therefore, it will not include the image that is actually part of this HTML page ("img/dude.gif").

Even if the Chilkat MHT component tried to statically extract URLs from the Javascript, it may try to include URLs that are not actually used in the HTML. In this case, "img/big.gif" is never actually included. However, "img/dude.gif" is included, but its URL was dynamically generated in the Javascript code, and therefore NOT visible to any software statically scanning for URLs.

The solution is to place the URL directly in the CSS or in the attributes of the HTML tags.


Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.