[問題] IE呈現XML檔的方式

看板Ajax作者 ( )時間17年前 (2008/04/07 19:30), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
我的伺服器是appWeb 網頁有提供HTTP上傳的功能 後端是以C++處理上傳的檔案 由於submit這個動作會reload網頁 所以我把form的target 設到隱藏iframe中 因此後端回傳的XML檔案會顯示在iframe裡(但設成隱藏 所以看不到) 片段程式碼如下: ---------------------------------------------------------------------------------- HTML <form target="if" action="/goform/abc.xml" method="post"> .... </form> <iframe name="if" onload="getObject()" style="display:none;"><iframe> <script> function getObject() { var tag=window.frames["if"].document.getElementsByTagName("abc")[0]; if(tag != null) { alert(tag.getAttribute("result")); } } </script> ----------------------------------------------------------------------------- XML <ajax-response> <response> <abc result="success"/> </response> </ajax-response> ----------------------------------------------------------------------------- 我想直接抓XML中的tag "abc" 然後取得它的屬性 並把結果show出來 所以寫了getObject() 在firefox底下 getElementsByTagName可以成功抓到我要的tag 並alert 但是IE卻抓不到tag~ 我用 window.frames["if"].document.getElementsByTagName("*") 跑迴圈顯示 發現firefox抓到的值是XML檔裡原有的tag (ajax-response、response、abc) 而IE卻是將XML解譯後的HTML碼 (HTML、HEAD、BODY、SPAN、FONT...) 請問 如何才能正確抓到XML中的tag 而不是IE自己解譯的無意義文字? 謝謝~ ^^ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.124.142.183 ※ 編輯: iambonnie 來自: 59.124.142.183 (04/07 19:32) ※ 編輯: iambonnie 來自: 59.124.142.183 (04/07 19:32)
文章代碼(AID): #17-WNKZj (Ajax)
文章代碼(AID): #17-WNKZj (Ajax)