spot the difference in the code :(
HI,
i have two html files index and index1.
on index javascript works but after a 1 sec or so redirects to something wired.
index1 doesnt work at all.
its a simple increase font size thing.
i'm new can any expert help?
Thanks
codes on files
index
-
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" src="jquery-1.2.6.pack.js">
</script>
<script type="text/javascript">
$(function() {
$('a').click(function() {
var os = $('p').css('font-size');
var num = parseFloat(os, 10);
var uom = os.slice(-2);
$('p').css('font-size', num / 1.4 + uom);
if(this.id == 'larger') {
$('p').css('font-size', num * 1.4 + uom);
}
})
})
</script>
</head>
<body>
<a href="#" id="larger">Larger</a>
<br/>
<a href="#" id="smaller">Smaller</a>
<p>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</p>
</body>
</html>
index1
-
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="default.css" rel="stylesheet" type="text/css" />
<script src="jquery-1.2.6.pack.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$('a').click(function(){
var os = $('p').css('font-size');
var num = parseFloat(os,10);
var oum = os.slice(-2);
console.log(oum);
$('p').css('font-size', num / 1.4 + uom);
if(this.id)=='large'){
$('p').css('font-size', num * 1.4 + uom);
};
});
});
</script>
</head>
<body>
<a href="#" id="larger">large</a><br />
<a href="#" id="smaller">small</a>
<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). </p>
</body>
</html>
[/quote]