동일한 도메인에있는 여러 URL에 대해 보안 영역 (인터넷 영역/로컬 인트라넷)을 얻고 싶습니다. 가장 좋은 해결책은 iFrame을 통해이 문제를 해결하는 것입니다. @ 테 무무. 코드가 작동합니다. 고맙습니다. 하지만 지금까지 한 가지 문제가 있습니다. 잘못된 텍스트가 표시됩니다. 페이지가 신뢰할 수있는 영역 (로컬 인트라넷)에 있지만 "신뢰할 수 없음"(인터넷 영역)을 표시합니다. 왜 그런가?iFrame에서 콘텐츠 가져 오기, 오류는 어디에 있습니까?
<html>
<head>
<script type="text/javascript">
function getZone() {
var text = new Array();
document.getElementsByClass('iframeNames');
var test;
for (var i = 0; i < document.frames.length; i++) {
try {
test = document.frame[i].contentWindow.document;
text[i] = "Trusted (Local Intranet)";
} catch (e) {
text[i] = "Untrusted (Internet Zone)";
}
} //end-for
var showText = getElementsByClass("zone");
for (var i = 0; i < showText.length; i++) {
setText(showText[i], text[i]);
};
} //end getZone()
function setText(showText, text) {
showText.innerHTML = text;
} //end setText
if (document.getElementsByClassName) {
getElementsByClass = function (classList, node) {
return (node || document).getElementsByClassName(classList);
};
}
</script>
</head>
<style type="text/css">
tr:nth-child(2n) {
background-color: #ddd;
}
.format {
background-color: #ffff;}
#formatierung {
margin-left: 10px;
margin-top: 30px;
font-family: Arial;
font-size: 13px;
}
</style>
<body>
<iframe src = "http://example.com" class = "iframeNames" width = "0"
height ="0"></iframe>
<iframe src = "http://example.com/index/" class = "iframeNames" width = "0"
height = "0"></iframe>
<script type = "text/javascript">
window.onload = function() {
getZone();
};
</script>
<div id = "formatierung">
<table width = "100%">
<tr class = "format"><td><h2>System</h2></td><td><h2>Check Security-Zone</h2></td></tr>
<tr><td>example1</td><td class = "zone"></td></tr>
<tr><td>example2</td><td class = "zone"></td></tr>
</table>
</div>
</body>
</html>
정확히 작동하지 않는 기능은 무엇입니까? 처음에 무엇을 필요로합니까? (나는 이것이 가능하다는 것을 당혹 스럽다.) –
이 줄은 :'value [i] = frames [i] .isTrustedIE()'이다. 'frames []'는 문서에있는 "window"객체들의 모임입니다. 콜렉션의 이러한 멤버에는'isTrustedIE()'라는 속성이 없으므로 스크립트에서 예외가 발생합니다. – Teemu
보안 영역의 결과가 표시되지 않으므로 텍스트를 표시하지 않습니다 (신뢰할 수 있음/신뢰할 수 없음). 먼저 iFrames를 반복해야합니다. frames [i] .isTrustedIE() 명령은 현재 URL의 보안 영역을 확인해야합니다. 이 명령이 옳은지 나는 모른다.이 진술에서 나는 확신 할 수 없었다.). – user1860908