2012-03-26 68 views
0

我正在嘗試從FrameSet中將innerHTML導出爲ex​​cel(.xlsx)。 有沒有像JavaScript這樣的「this.document.getElementById('completeFrameSet')。InnerHTML」?從Frameset中獲取InnerHTML

<frameset onLoad="init()" onResize="balken()" framespacing="0" frameborder="0" cols="286,*" id="completeFrameSet"> 
    <frameset id="links" rows="32,*"> 
    <frame marginheight="0" marginwidth="0" scrolling="no" name="obLi" src="content_LeftTop.php > 
    <frame marginheight="0" marginwidth="0" scrolling="no" name="untLi" src="content_LeftBottom.php"> 
    </frameset> 
    <frameset id="rechts" rows="32,*"> 
    <frameset id="oben" cols="*,13"> 
     <frame marginheight="0" marginwidth="0" scrolling="no" name="obRe" src="content_RightTop.php"> 
     <frame scrolling="no" src="leer.html"> 
    </frameset> 
    <frame marginheight="0" marginwidth="0" scrolling="auto" name="untRe" src="content_RightBottom.php"> 
    </frameset> 
</frameset> 

映入眼簾, 凱文

+0

你能否更詳細地描述你的問題?您正在尋找另一種獲取內容的方式,而不是使用「document.getElementById('completeFrameSet')。InnerHTML」? – 2012-03-26 12:22:11

+0

它告訴我「undefined」:) 所以我需要一種方法來獲取我的Frameset中的所有HTML數據。 我使用哪種方式對我來說並不重要。 – 2012-03-26 12:33:05

+0

可以幫助:http://stackoverflow.com/a/11107977/2835520 – IgniteCoders 2015-05-08 07:14:26

回答

0

嘗試使用的document.getElementById( '元素')。innerHTML的無前綴 「這個」。您也可以使用庫jQuery並使用$(element).html()方法。它還返回元素的內容作爲字符串

+0

呵呵,現在我正在獲取我上面寫的html代碼。 但不是HTML,.php網站已經生成。 我嘗試從我的完整框架集中得到結果。 – 2012-03-26 13:03:33

+0

我對PHP並不熟悉,但我希望對你有所幫助:) – 2012-03-26 14:13:20

+0

沒有抱歉,沒有提供幫助:-)我嘗試在構建頁面後獲取完整的HTML內容。 如果我做一些數據庫選擇並顯示結果與一個PHP文件,我嘗試獲得所有生成的內容,只需點擊一下。 – 2012-03-27 12:22:21

0
//Here is how i get the content of the body of a iframe 
var iframeElement = document.getElementById('myFrame'); 
var iframeDocument = iframeElement.contentDocument || iframeElement.contentWindow.document; 
var frameContent = iframeDocument.getElementsByTagName('BODY')[0].innerHTML; 

感謝algorhythmanswer