Jeans & Development:2012年 05月の記事

jQueryでオブジェクトのスクリプト属性が書き換えられなくなっていた件について [Jeans]

2012年5月16日

このブログでは、ほぼ1年ぶりの記事になる。

以前、このブログでカラム幅をはみ出す画像の表示に関して、Jeansで表示されるHTML中で次のように処理していた。

<script type="text/javascript">
function imgpopup(obj,width,height){
  var href=obj.src+"";
  href=href.substring(href.indexOf("/media/",0)+1,href.length);
  href="?imagepopup=skin&image_path="+href+"&alt_text="+obj.alt;
  window.open(href,'imagepopup','status=no,toolbar=no,scrollbars=no,resizable=yes,width='+width+',height='+height);
}
$("#mainwrapper img").each(function(){
  if (510<$(this).attr("width")) {
    $(this).css("cursor","pointer");
    $(this).attr("onclick","imgpopup(this,"+parseInt($(this).attr("width"))+","+parseInt($(this).attr("height"))+");");
    $(this).attr("height",Math.floor($(this).attr("height")*510/$(this).attr("width")));
    $(this).attr("width",510);
  }
});
</script>