2011년 9월 2일 금요일
[Javascript] Image to Clipboard
투명처리 안됨
/*
* 이미지(url로부터) 클립보드 저장 / IE전용
*/
function copyClipboardImageByUrl(url) {
var userAgent = navigator.userAgent;
var isIE = userAgent.indexOf("MSIE") != -1;
if (!isIE) {
alert("익스플로러에서만 가능합니다.");
return;
}
var body = document.body;
var iframe = document.createElement("iframe");
iframe.style.display = "none";
body.appendChild(iframe);
var idoc = iframe.contentWindow.document;
var ihtml = idoc.createElement("html");
idoc.appendChild(ihtml);
var ibody = idoc.createElement("body");
ihtml.appendChild(ibody);
var img = idoc.createElement("img");
img.src = url;
ibody.appendChild(img);
if (ibody.createControlRange) {
var cR = ibody.createControlRange();
cR.addElement(img);
cR.execCommand('Copy');
}
alert("클립보드에 저장되었습니다.");
}
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기