Tag Archive for js

JS スタイルシートにアクセスする

	function fitFlash(w,h){
document.getElementById('flashLoader').style.width = w;
document.getElementById('flashLoader').style.height = h;
}

source

Load FancyZoom.js

	<script src="/js/FancyZoom/js-global/FancyZoom.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/FancyZoom/js-global/FancyZoomHTML.js" type="text/javascript" charset="utf-8"></script>

source

Preload

// Preloader

$(window).bind('load', function(){
var preload = [
'/assets/images/alert_ticked.jpg',
'/assets/images/alert_unticked.jpg'
];
$(document.createElement('img')).bind('load', function(){
if(preload[0]) this.src = preload.shift();
}).trigger('load');

});

source

compressing html, css, xml, js

# Compress output
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch MSIE !no-gzip !gzip-only-text/html

source

load jquery.js

<script src="http://www.do-planning.jp/jsLib/jquery.js" type="text/javascript" charset="utf-8"></script>

source

Load jquery.scrollTo.js and jquery.localscroll.jp

<script src="http://www.do-planning.jp/jsLib/jquery.scrollTo-min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://www.do-planning.jp/jsLib/jquery.localscroll-min.js" type="text/javascript" charset="utf-8"></script>

source

Load jquery.js

<script src="http://www.do-planning.jp/jsLib/jquery.js" type="text/javascript" charset="utf-8"></script>

source

jQuery Flash Basic Template

	$('#hello').flash({
src: 'hello.swf',
width: 320,
height: 240
});

source

Elapsed time string from time in seconds

function elapsedTime (createdAt)
{
var ageInSeconds = (new Date().getTime() - new Date(createdAt).getTime()) / 1000;
var s = function(n) { return n == 1 ? '' : 's' };
if (ageInSeconds < 0) {
return 'just now';
}
if (ageInSeconds < 60) {
var n = ageInSeconds;
return n + ' second' + s(n) + ' ago';
}
if (ageInSeconds < 60 * 60) {
var n = Math.floor(ageInSeconds/60);
return n + ' minute' + s(n) + ' ago';
}
if (ageInSeconds < 60 * 60 * 24) {
var n = Math.floor(ageInSeconds/60/60);
return n + ' hour' + s(n) + ' ago';
}
if (ageInSeconds < 60 * 60 * 24 * 7) {
var n = Math.floor(ageInSeconds/60/60/24);
return n + ' day' + s(n) + ' ago';
}
if (ageInSeconds < 60 * 60 * 24 * 31) {
var n = Math.floor(ageInSeconds/60/60/24/7);
return n + ' week' + s(n) + ' ago';
}
if (ageInSeconds < 60 * 60 * 24 * 365) {
var n = Math.floor(ageInSeconds/60/60/24/31);
return n + ' month' + s(n) + ' ago';
}
var n = Math.floor(ageInSeconds/60/60/24/365);
return n + ' year' + s(n) + ' ago';
}

// Make date parseable in IE
function fixDate (d)
{
var a = d.split(' ');
var year = a.pop();
return a.slice(0, 3).concat([year]).concat(a.slice(3)).join(' ');
}

source

JS 小さい別ウインドウで開く

<script language="Javascript">
<!--
function newwin(){
var win1=window.open('***.htm','newwindow',
'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=200,height=200');
}
//-->
</script>

source