jQueryでpopupな野良プラグイン
jQuery でpopupなプラグインを作ってみたよ。
たしか既に公開されてるのがあったような気がするけど、 引数の種類とか思い出す為にも自作してみた。
jQuery.extend({//START: jQuery.extend.
/**
* flattenAttrs.
*/
flattenAttrs : function (o, s)
{
var retval = []
$.each(o||{}, function (k, v)
{
retval.push(k+'='+v);
});
return retval.join(s||',');
}//END: flattenAttrs.
});//END: jQuery.extend.
jQuery.fn.extend({//START: jQuery.fn.extend.
/**
* popup.
*/
popup : function (name, options)
{
var settings = {
'titlebar' : 'no',
'resizable' : 'yes',
'scrollbars' : 'yes',
'left' : screen.width,
'top' : screen.height,
'width' : screen.availWidth,
'height' : screen.availHeight
}
options = jQuery.extend({}, settings, options||{});
name = name || 'piggy';
return this.filter('a[href]')
.click(function (evt)
{
window
.open(this.href, name, jQuery.flattenAttrs(options))
.focus();
return false;
})
.end();
}//END: popup.
});//END: jQuery.fn.extend.
これを読み込ませておいて、使うときはこんな感じ。
<script type="text/javascript">
//<![CDATA[
$(function (){
$('a.popup').popup();
});
//]]>
</script>
見事に車輪です。
- Posted at:
- 2007/09/23 05:23:52
- 0 Comments
- 0 TrackBacks
- Tags:
- JavaScript
- jQuery
- plugin
- Trackback:
- http://humming.via-kitchen.com/2007/09/23/jquery-popup-nora-plugin/trackback/
TrackBacks
まだ登録されていません。
Comments
まだ登録されていません。