에 에 대한 URL을 설정하는 가장 좋은 방법은 무엇입니까. 내 고객은 위치 또는 src 중 하나를 사용하여 프레임 URL을 설정/변경하고 싶습니다. 언젠가 위치 일, 언젠가 src 일 그래서 나는 무슨 일이 일어나는지 알게 될 것입니다.
나는 3 개의 html 파일을 만듭니다 : parent.html, left.html, right.html. 여기에 여기에 parent.html 내용내가 지금 <strong>프레임</strong> 및 <strong>프레임</strong> 함께 일하고 있어요 및 I 프레임의 URL을 변경하는 방법에 대해 너무 혼란 스러워요 <frameset>
<frameset cols="*,*">
<frame id="left" src="left.html">
<frame id="right" src="right.html">
</frameset>
이 경우에 SRC
<head> <script> function LocationThis() { window.frames['innerleft'].location = "http://prntscr.com"; } function SrcThis() { window.frames['innerleft'].src = "http://prntscr.com"; } function LocationOther() { window.parent.frames['right'].location = "http://prntscr.com"; } function SrcOther() { window.parent.frames['right'].src = "http://prntscr.com"; } </script> </head> <body> <h1>Left</h1> <button type="button" onclick="LocationThis();">Location this</button> <button type="button" onclick="SrcThis();">Src this</button> <button type="button" onclick="LocationOther();">Location other</button> <button type="button" onclick="SrcOther();">Src other</button> <hr/> <iframe id="innerleft" src="" /> </body>
만
내용 left.html 작품이다. 그럼 위치가 일 때 이 작동하지 않습니다. 좋아, 지금은 변경이//window.parent.frames['right'].location = "http://prntscr.com";
window.parent.frames[1].location = "http://prntscr.com";
그런 위치 잘 작동과 같은 스크립트. 따라서 프레임 [ 'right']. src 및 프레임 [1]. 위치입니다. 그러나 모든 경우가 아니며 때때로 프레임 [ 'right']. 위치도 작동합니다. 나는 프레임 ID 만 사용하여 이름을 제거하면 나는 위치를의
<frame name="right" src="right.html">
를 사용해야합니다. 아, IE 덕분에 src를 가져갈 수 없으므로 확인해야합니다.
try {
window.parent.frames["id"].src = {url};
}
catch(er) {
window.parent.frames["id"].location = {url};
}
이 모든 것들에 대한 깔끔한 해결책이 있습니까?
http://stackoverflow.com/questions/1203068/why-should-i -not-use-html-frames –
10 년 전의이 프로젝트.나는 IE5, 프레임 셋을 다루고있다 ... 그들에게 변경을 설득 할 수 없다. –