HTML :
$(document).ready(function()
{
// executes when HTML-Document is loaded and DOM is ready
alert("(document).ready was called - document is ready!");
});
또는
이 직후 자바 스크립트를 실행하는 신체의 onLoad
속성에 함수를주기 페이지가로드되었습니다 :
<body onload="myFunction()">
window.load
그러나 완전히로드 할 페이지를 기다리는이 포함 내부 프레임, 이미지 등
$(window).load(function()
{
// executes when complete page is fully loaded, including all frames, objects and images
alert("(window).load was called - window is loaded!");
});
window.load
는 내장 된 자바 스크립트 방법이 몇 가지 단점을 가지고하는 것으로 알려져있다 오래된 브라우저 (IE6, IE8, 오래된 FF 및 Opera 버전)에서는 일반적으로 모두 작동합니다.
window.load
이렇게 신체의 onload 이벤트에 사용할 수 있습니다.
window
요소의로드 메소드를 jQuery AJAX의로드 메소드와 혼동하지 마십시오 !!!
HTML :
<html>
<head>
<title> Popup Box DIV </title>
</head>
<body>
<div id="popup_box"> <!-- OUR PopupBox DIV-->
<h1>This IS A Cool PopUp</h1>
<a id="popupBoxClose">Close</a>
</div>
<div id="container"> <!-- Main Page -->
<h1>sample</h1>
</div>
</body>
</html>
CSS : 여기
// This is the AJAX load
$("#MyDivID").load("content_page.txt");
샘플이 나를 위해 일입니다
<style type="text/css">
/* popup_box DIV-Styles*/
#popup_box {
display:none; /* Hide the DIV */
position:fixed;
_position:absolute; /* hack for internet explorer 6 */
height:300px;
width:600px;
background:#FFFFFF;
left: 300px;
top: 150px;
z-index:100; /* Layering (on-top of others), if you have lots of layers: I just maximized, you can change it yourself */
margin-left: 15px;
/* additional features, can be omitted */
border:2px solid #ff0000;
padding:15px;
font-size:15px;
-moz-box-shadow: 0 0 5px #ff0000;
-webkit-box-shadow: 0 0 5px #ff0000;
box-shadow: 0 0 5px #ff0000;
}
#container {
background: #d2d2d2; /*Sample*/
width:100%;
height:100%;
}
a{
cursor: pointer;
text-decoration:none;
}
/* This is for the positioning of the Close Link */
#popupBoxClose {
font-size:20px;
line-height:15px;
right:5px;
top:5px;
position:absolute;
color:#6fa5e2;
font-weight:500;
}
</style>
JS :
<script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
// When site loaded, load the Popupbox First
loadPopupBox();
$('#popupBoxClose').click(function() {
unloadPopupBox();
});
$('#container').click(function() {
unloadPopupBox();
});
function unloadPopupBox() { // TO Unload the Popupbox
$('#popup_box').fadeOut("slow");
$("#container").css({ // this is just for style
"opacity": "1"
});
}
function loadPopupBox() { // To Load the Popupbox
$('#popup_box').fadeIn("slow");
$("#container").css({ // this is just for style
"opacity": "0.3"
});
}
});
</script>
당신은 아직도 내가 그것을 작동하지 않았다 – codebot