Nov
5
2009
Description: It will increase and decrease the font-size of the text…
Code:
<div id="changeFont">
<a href="#" class="increaseFont">A<sup>+</sup></a>
<a href="#" class="decreaseFont">A<sup>-</sup></a>
<a href="#" class="resetFont">R</a>
</div>
Show Spoiler »
$(document).ready(function()
{
var d=$('html').css('font-size');
$(".resetFont").click(function()
{
$('html').css('font-size',d)
}
);
$(".increaseFont").click(function()
{
var a=$('html').css('font-size');
var b=parseFloat(a,10);
var c=b*1.2;
$('html').css('font-size',c);
return false
}
);
$(".decreaseFont").click(function()
{
var a=$('html').css('font-size');
var b=parseFloat(a,10);
var c=b*0.8;
$('html').css('font-size',c);
return false
}
)
}
);
Save this code as .js file… Or combine it with your other .js files…
Continue reading
VN:F [1.6.5_908]
Rating: 0.0/10 (0 votes cast)
VN:F [1.6.5_908]
no comments | tags: ajax, ajax scripts, javascript, Jquery Tricks | posted in Jquery Tricks
Nov
5
2009
Description: Add a “top” anchor link at your page with scroll effect.
My Preview
XHTML File
At this at your media box… Or inject it to your body and make a CSS to position the links…
<a href="#" class="top"><b>TOP</b></a>
JS File
<script type="text/javascript">
$(document).ready(function(){
$('a.top').click(function(){
$('html, body').animate({scrollTop: '0px'}, 300);
return false;
});
});
</script>
Continue reading
VN:F [1.6.5_908]
Rating: 10.0/10 (1 vote cast)
VN:F [1.6.5_908]
no comments | tags: ajax, ajax scripts, effects, javascript, Jquery Tricks | posted in Jquery Tricks
Sep
12
2009
Description: This will speed up your site by caching an compresing your javascript and css files with php…
Compress CSS Files
1. Add this code at the top of the your CSS document and save it as:
Example: myfile.css.php
Show Spoiler »
<?php
// initialize ob_gzhandler function to send and compress data
ob_start ("ob_gzhandler");
// send the requisite header information and character set
header ("content-type: text/css; charset: UTF-8");
// check cached credentials and reprocess accordingly
header ("cache-control: must-revalidate");
// set variable for duration of cached content
$offset = 60 * 60;
// set variable specifying format of expiration header
$expire = "expires: " . gmdate ("D, d M Y H:i:s", time() + $offset) . " GMT";
// send cache expiration header to the client broswer
header ($expire);
?>
Compress JS Files
1. Add this code at the top of the your JS document and save it as:
Example: myfile.js.php
Show Spoiler »
<?php
// initialize ob_gzhandler function to send and compress data
ob_start ("ob_gzhandler");
// send the requisite header information and character set
header ("content-type: text/javascript; charset: UTF-8");
// check cached credentials and reprocess accordingly
header ("cache-control: must-revalidate");
// set variable for duration of cached content
$offset = 60 * 60;
// set variable specifying format of expiration header
$expire = "expires: " . gmdate ("D, d M Y H:i:s", time() + $offset) . " GMT";
// send cache expiration header to the client broswer
header ($expire);
?>
VN:F [1.6.5_908]
Rating: 10.0/10 (2 votes cast)
VN:F [1.6.5_908]
no comments | tags: php, PHP Tricks | posted in Friendster Tricks, PHP Tricks