2017-03-06 1 views
0

div가 있지만 액세스 제어 허용 원점 문제에 새 페이지를 표시하고 싶습니다.요청한 리소스에 Access-Control-Allow-Origin '헤더가 있습니다.

예를 들어, 나는 ==============================

를 표시 www.naver.com하려고 ========================

<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css"> 
    <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script> 
    <script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> 
    <script src="js/jquery.ajax-cross-origin.min.js"></script> 
    <script> 
     $(document).ready(function() { 
     var url = 'http://www.naver.com'; 
    jQuery.ajax({ 
      type:"GET", 
      url : url, 
      dataType:"jsonp", 
      crossOrigin: true,   
      success : function(data) { 
       console.log('success'); 
       console.log('success:'+url); 
       }, 
      error : function(data) { 
       console.log('error'); 
       } 
     }); 
    $('#openPage').load(url); 

    }); 
</script> 
<style> 
    #btn{ 
     width: 100%; 
     height:50px; 
    } 

</style> 
</head> 
<body> 
<!-- <div id="btn"> 
    <button>button</button> 
</div> --> 
<div id='openPage'></div> 

</html> 
+1

코드를 게시하고 화면을 캡처하지 마십시오. –

답변

0

요청을하는 사이트가 사이트에 사이트 권한을 부여한 경우에만 원산지 AJAX 요청을 할 수 있습니다. Naver.com은 그렇게하지 않으므로 그렇게 할 수 없습니다. 그 주위에 방법이 없습니다. 페이지를 표시하고 JavaScript 액세스에 신경 쓰지 않으면 iframe이 가장 가까운 것입니다.

0

응답 http 헤더에는 "Access-Control-Allow-Origin"이 포함되어야하며 이는 Naver.com에서 수행해야합니다. 변경할 수 없기 때문에 Naver.com의 콘텐츠를로드하고 페이지로 보낼 프록시 서버를 만들 수 있습니다.

관련 문제