4,561,322 th visitor since 2017.2.1 ( Today : 6069 )
Programming
No. 536
Name. swindler
Subject. 웹페이지 copy & paste 를 위한 방법
Main Cate. HTML
Sub Cate.
Date. 2009-01-15 13:08
Hit. 4214 (211.43.206.101)
File.
웹페이지를 긁으면 text만 복사가 되서,
가끔 캡쳐를 받곤 하는데,
아무래도 귀찮기도 하고 나중에 보기 좋지 않다.

그래서 그냥 대충 만들었다.

입력폼에는 아래와 같은 형태로 놓고,
<iframe id="HTMLEDITOR" src="about:blank" border=0 height="300" width="600" scrolling="auto" frameborder=1></iframe>

스크립트를 아래와 같이 사용한다.
<script language=javascript>
function Editinit()
{
var Mysource = "<link rel='stylesheet' type='text/css' href='/css/front.css'><body style='margin:5 5 5 5;'>";
HTMLEDITOR.document.designMode="On";
HTMLEDITOR.document.open("text/html");
HTMLEDITOR.document.write(Mysource);
HTMLEDITOR.document.close();
HTMLEDITOR.document.body.style.fontSize = "9pt";
HTMLEDITOR.document.body.style.fontFamily = "굴림";
//HTMLEDITOR.document.oncontextmenu = new Function("return false;");
}

function check_html()
{
alert(HTMLEDITOR.document.body.innerHTML);
}
</script>

다른건 별로 안 중요하고
designMode = "On"이 중요하다.

이렇게 되면 html 형태로 복사가 되고,
이미지의 경우 절대경로로 바꿔어서 넘어오는것으로 알고 있다. (혹시 아님?)


아직 공개하기는 좀 그렇지만,
이 html을 파싱해서 image 경로를 잘라낸 다음에, 이 이미지를 URLConnection으로 받아서
서버에 저장한 다음에
경로를 변경해서 보여주게끔....

여기까지는 만들었다.
근데 아마 사용하다보면 좀더 세밀한 변환은 필요할것 같고,
네이버 이미지인가 referer 체크하는 애들이 좀 있는데, 그건 그때 생각해봐야될듯.

하여튼, 이 기능 하나로 아주 편해졌다 ^^

[바로가기 링크] : http://coolx.net/cboard/develop/536



Name
Password
Comment
Copyright © 1999-2017, swindler. All rights reserved. 367,611 visitor ( 1999.1.8-2004.5.26 ), 2,405,771 ( -2017.01.31)

  2HLAB   2HLAB_Blog   RedToolBox   Omil   Omil_Blog