본문 바로가기

카테고리 없음

php, 문자열 치환, str_replace 예제

반응형

$chk_content = str_replace("img", "img name='target_resize_image[]' onclick='popimage(this)' style='cursor:pointer;'", $row_view->content);

[출처] php str_replace기능|작성자 제이옹



//이미지를 원본사이즈로 열기 
function popimage(arg){
  var img_src = arg.src;
  var winwidth = arg.offsetWidth;
  var winheight = arg.offsetHeight;
  //alert(img_src);
  var look='scrollbars=yes,width=10,height=10,'
  popwin=window.open("","",look);
  popwin.document.open();
  popwin.document.write("<html>\n"); 
  popwin.document.write("<head>\n");
  popwin.document.write('<title>Image Window</title><body topmargin=0 leftmargin=0>');
  popwin.document.write("<title>**</title>\n"); 
  popwin.document.write("<sc"+"ript>\n"); 
  popwin.document.write("function resize() {\n"); 
  popwin.document.write("pic = document.il;\n"); 
  //imgwin.document.write("alert(eval(pic).height);\n"); 
  popwin.document.write("if (eval(pic).height) { var name = navigator.appName\n"); 
  popwin.document.write("  if (name == 'Microsoft Internet Explorer') { myHeight = eval(pic).height + 40; myWidth = eval(pic).width + 38;\n"); 
  popwin.document.write("  } else { myHeight = eval(pic).height + 9; myWidth = eval(pic).width; }\n"); 
  //imgwin.document.write("  clearTimeout();\n"); 
  popwin.document.write("  var height = screen.height;\n"); 
  popwin.document.write("  var width = screen.width;\n"); 
  popwin.document.write("  var leftpos = width / 2 - myWidth / 2;\n"); 
  popwin.document.write("  var toppos = height / 2 - myHeight / 2; \n"); 
  popwin.document.write("  self.moveTo(leftpos, toppos);\n"); 
  popwin.document.write("  self.resizeTo(myWidth, myHeight);\n"); 
  popwin.document.write("}else setTimeOut(resize(), 100);}\n"); 
  popwin.document.write("</sc"+"ript>\n"); 
  popwin.document.write("</head>\n"); 
  popwin.document.write('<img style=cursor:hand; onclick="self.close()" src="'+img_src+'" name=il onload="resize();"></body>');
  popwin.document.close();
 }

[출처] php str_replace기능|작성자 제이옹


출처 : http://blog.naver.com/jpooh000/220082604027


반응형