Web Source2014. 9. 25. 22:12

네이버에서는 검색이 어려운 블로그입니다. 구글검색을 이용해 주세요.



같은 도메인 안에서는 iFrame의 내용을 수정하는 것이 가능했는데

다른 도메인의 내용은 수정할 수가 없었다.


iframe 에 의해서 불러온 today.htm 을 화면에 보여주지 않으면서

html 내용(strRawContents)을 내 마음대로 수정할 수 있다.

한글도 잘 된다.


var oFrame = document.getElementById("frmFile1");

var strRawContents = oFrame.contentWindow.document.body.childNodes[0].innerHTML;


<body>

<iframe id="frmFile1" style="display: none;" src="today.htm"></iframe>


===========================================


Javascript - 같은 도메인만 가능하다.

같은 도메인은 방법이 많이 있다.

원래는 iFrame 을 사용하고 있었는데 아주 좋은 방법을 찾았다.


iFrame Content

http://code.google.com/p/microajax/


<script type="text/javascript" src="microajax.minified.js"></script>

microAjax("/resource/url", function (res) {

  alert (res);

});


==================================


PHP - 다른 도메인도 가능하다.


내가 찾은 최고의 방법은 snoopy class php 이다.

그런데 가끔 경고(주의)가 나와서 오류처리를 해야 한다....


간단한 방법은 두 가지인데 다 되는건 아닌것 같다.

또 둘 중 하나만 되는 경우도 있으니 다 확인해야 한다.


먼저 fsockopen 이다.

$server_ip 는 http:// 빼고 도메인 주소만 넣어야 한다.


// $fp = @fsockopen("www.tistory.com","80",$errno,$errstr,1);


$fp = @fsockopen($server_ip,$portbase,$errno,$errstr,1);

if (!$fp) { 

print "<p>Connection refused, the server appears to be offline.</p>";

exit;

} else { 

fputs($fp, "GET /index.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");

while (!feof($fp)) {

$info = fgets($fp);

}

fclose($fp);

print $info;

}


========

두번째는 cURL 이다.

$ch = curl_init("/resource/url");

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$info = curl_exec($ch);       

curl_close($ch);

echo $info;



'Web Source' 카테고리의 다른 글

CSS style font-weight Property  (0) 2014.10.21
Center a new popup window even on dualscreen with javascript  (0) 2014.10.06
PHP - Browser detection - IE, Firefox, Safari, Chrome  (0) 2014.09.22
iFrame auto resizer  (0) 2014.09.04
Div Zoom iFrame  (0) 2014.09.03
Posted by 영육치료