당신은 어떻게 브라우저를 중지에서'hourglassing'자바 스크립트를 수행(중지 색인기)?
-
06-09-2020 - |
문제
쓰 작은 HTML 웹 페이지의 일부와 함께 매우 간단 하에서 자바스크립트,그것을 발견한 후에 그것은,그것을 지켜 원 회전(firefox).본는 많은 시간 다른 페이지에서 항상이라고 생각했 자바스크립트 오류 또는 반복 문제가 있지만,이 프로그램을 실행 했다 확실히 한다.
여기에는 하나의 예로 작 웹 페이지 않는다.한 후 버튼을 클릭하고 그것은 프로세스,색인기(주셔서 감사합니다 Kooilinc 기간)유지한다.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>Grade Tester</title>
<script language="javascript" type="text/javascript">
function calculate()
{
var grade = document.getElementById("grade").value.toUpperCase();
switch (grade)
{
case "A":
document.write("Outstanding Achievement");
break;
case "B":
document.write("Above Average");
break;
case "C":
document.write("Average Achievement");
break;
case "D":
document.write("Low Passing Grade");
break;
case "F":
document.write("Failing Grade");
break;
}
}
</script>
</head>
<body>
Grade:<input type="text" id="grade" />
<br /><input type="button" value="Get Result" onclick="calculate()" />
</body>
</html>
나는 그것을 막을 수 없을 타격하여 중지(마우스 오른쪽 버튼을 클릭하고 중지).
나는 무엇을 얻을 자바스크립트를 정지 처리(또는 브라우저 처리를 중지)후 스크립트가 완료되면?
Note1:이에 발생한 FF4.01 지,IE 에서 또는 크롬(이를 위해 코드 샘플).
Note2:나는 창입니다.stop()함수 후 스위치 진술,그리고 그것을 멈추지 않았 색인기.
당 Lekensteyn 의 응답,문서입니다.close()스위치 후 문을 해결,하지만 여기를 들어지 않았던 두근 두근에서 모두와 사용하지 않 문서입니다.close().
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>Lab 9.1</title>
</head>
<body>
<script language="javascript" type="text/javascript">
var phrase = "Every good boy does fine goes on the line."
document.write(phrase.length + "<br />");
for(var i = 0; i < phrase.length; i++)
{
document.write(phrase.charCodeAt(i) + " ");
}
document.write("<br />");
document.write(phrase.toLowerCase() + "<br />");
document.write(phrase.toUpperCase() + "<br />");
</script>
</body>
</html>
해결책
를 호출한 후에 document.write()
, 를 호출해야 합니다 document.close()
는 경우 문서 이전에 폐쇄되지 않습니다.
기본적으로,이는 일:
- 페이지 얻어 구문 분석
- 스크립트가 처리
- 페이지"closed"(
document.close()
)
는 경우 document.write()
라에서 2 단계,그것은 완료됩니다에 단계 3.을 넘어 3 단계를 호출하는 경우 document.write
, 에,당신은 열기 페이지를 다시 있지만,페이지가 닫지에서 자신 FF(에 대한 확실하지 않는 다른 사람).당신이 그것을 닫를 호출하여 document.close()
.
내가 이것을 발견했을 때 나는 데 필요한 창을 열고 쓰고 그것으로 신속하게 FF.
var win = window.open();
win.document.write("something");
// the next line is required to finish the page
win.document.close();
동일하게 적용하여 귀하의 경우:
<script type="text/javascript">
function calculate()
{
var grade = document.getElementById("grade").value.toUpperCase();
switch (grade)
{
case "A":
document.write("Outstanding Achievement");
break;
// removed some cases
case "F":
document.write("Failing Grade");
break;
}
// finish the document
document.close();
}
</script>