2017-03-17 183 views
0

我試圖在一個頁面中的iframe隱藏導航欄和標題中的iframe

代碼我使用的HTML頁面加載到隱藏標題和導航欄:

 <div id="frame2"><iframe width="100%" height="600px" margin-top="-350px" id="frame1" src="http://mls.searchfloridahomelistings.com/i/Neigbs_Bear_Lake_1" frameborder="0" allowfullscreen="allowfullscreen"></iframe></div> 

我已經嘗試了所有的建議,我可以找到使用JavaScript和沒有工作

當我檢查在谷歌我可以添加顯示:無;在CSS類:導航欄逆矩陣以及它隱藏一切,但是當我嘗試添加JavaScript它不工作:

<script type="text/javascript"> var isInIFrame = (window.location != window.parent.location);if(isInIFrame==true)document.getElementsByClassName("navbar-inverse")[0].style.display = "none";}</script> 

我也試圖從這裏其他職位給出的實例和其他論壇的幾個變化

它正在加載的網頁是http://www.searchfloridahomelistings.com/altamonte-springs-homes-for-sale/bear-lake-homes-for-sale/

是否因爲iframe的網址與網站的網址不同 - crossscripting?

我不是很熟悉JavaScript,所以任何幫助將不勝感激!

+0

當從iFrame中的SRC-URL是不一樣的主機域名,那麼你沒有獲得通過JS iFrame的內容。請看下面的資源:[CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS),[同源策略](https://developer.mozilla.org/ en-US/docs/Web/Security/Same-origin_policy)和[this](http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy)SO線程。如果啓用CORS,它會啓動 – empiric

+0

謝謝我會看看 – John

回答

0

你不能因爲iframe有另一個範圍,所以你不能訪問它的樣式或用javascript來改變它的內容。

它實際上另一個頁面