DOM元素全螢幕顯示解決方案,dom全螢幕顯示
<script type="text/javascript"> function goFullscreen(id) { // Get the element that we want to take into fullscreen mode var element = document.getElementById(id); // These function will not exist in the browsers that don't support fullscreen mode yet, // so we'll have to check to see if they're available before calling them. if (element.mozRequestFullScreen) { // This is how to go into fullscren mode in Firefox // Note the "moz" prefix, which is short for Mozilla. element.mozRequestFullScreen(); } else if (element.webkitRequestFullScreen) { // This is how to go into fullscreen mode in Chrome and Safari // Both of those browsers are based on the Webkit project, hence the same prefix. element.webkitRequestFullScreen(); } // Hooray, now we're in fullscreen mode! }</script><img class="video_player" src="image.jpg" id="player"></img><button onclick="goFullscreen('player'); return false">Click Me To Go Fullscreen! (For real)</button>
這樣就可以實現全螢幕顯示了,但是DOM元素的尺寸不會改變。別擔心,下面會幫你解決這個問題。
<style type="text/css"> .player:-webkit-full-screen { width: 100%; height: 100%; } .player:-moz-full-screen { width: 100%; height: 100%; }</style><img class="video_player" src="image.jpg" id="player3"></img><button onclick="goFullscreen('player');">Click Me To Go Fullscreen! (All the way)</button>
這樣對大部分DOM元素都起作用,但是對於iframe元素,還需添加allowFullScreen這個屬性。
<iframe src="iframe_src.html" width="400" height="300" allowFullScreen></iframe>
ok,大功告成!
reference: http://www.jwplayer.com/blog/using-the-browsers-new-html5-fullscreen-capabilities/
在HTML中,開啟的視窗怎訪問與控制父級視窗的Dom的元素?
比如說要找父級視窗中的XX元素
parent.document.getElementById('XX')
就在正常用時前邊加個parent.就代表父級視窗了。
DOM子項目問題
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script>
window.onload=function()
{
var obj=document.getElementsByTagName("div");//取得所有div標籤
alert(obj.length);//這個是顯示所有DIV標籤的個數
}
</script>
</HEAD>
<BODY>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</BODY>
</HTML>