외부 html 소스를 jQuery 모바일 페이지에 동적으로 통합하려고합니다. 성공적으로 외부 HTML을 통합 할 수 있지만 일반 HTML (jQuery 모바일이 영향을받는 HTML이 아닌)처럼 보입니다. 어느 누구도 제가 잘못하고있는 것을 제안 할 수 있습니까?외부 html을 jQuery Mobile 페이지에 통합
홈페이지 HTML :
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css"
/>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://jqueryui.com/ui/jquery-1.7.1.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>
<script>
$(document).ready(function() {
$("#main").load('externalHtml.html');
//$("#main").append('externalHtml.html');
//$("#main").load('externalHtml.html #contain');
//$("#main").page();
});
</script>
</head>
<body>
<div data-role="content">
<div id="main"></div>Main Page</div>
</body>
externalHtml.html :
이<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css"/>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://jqueryui.com/ui/jquery-1.7.1.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>
</head>
<body>
external html
<div data-role="content" id="contain">
<input type="search" name="name" id="name" value="" />
</div>
</body>
</html>
큰 일했다, 감사합니다! –
좋은! 하지만 어떻게 URL을 해시를 업데이 트합니까? – Magico
@Magico'window.location.hash = 'some-hash'; '를 사용하여 URL을 업데이트하거나 최신 브라우저에서 pushState API를 사용하여 해쉬를 넘어서 URL을 업데이트 할 수 있습니다. – Jasper