2012-11-26 29 views
2

我們的客戶端有兩個網站具有相同的內容,因此我們刪除了一個,並在其中一個域中使用了蒙版前進,因此仍覺得這兩個網站都在那裏。在屏蔽域中強制執行Windows位置更改

然後,我們使用了JavaScript的甜美試用版來檢查網站是否通過蒙版框架進行訪問,以便在jQuery中進行微小的美學修改。

try 
{ 
if (top.document.domain != self.document.domain); 
} 
catch(e) 
{ 
// jQuery to change a few colors and positions. 
} 

所有這些作品充滿了想象,除了,如果你想使用的標題鏈接從網站的屏蔽形式到實際域去了,失敗了,你留在屏蔽形式力,無論我們使用哪種方法來更改Windows位置。

我知道我們可以通過不使用屏蔽轉發和自定義iframe來避免這種情況,以便標題鏈接位於iframe之外。但我們寧願不這樣做,因爲我們將不得不參與IT部門,他們不願意進行更改。如果沒有解決方案,我們顯然會這樣做。希望有一個!

鏈接到真正的工作地點:

假面域名:http://mdpa.com/

實際的域:http://worthe.com/

+0

你能在行動後的一個例子。 – gkiely

回答

1

您可以通過更改標題鏈接的目標實現。

target="_top" 

沒有target屬性,它默認爲iframe。由於您使用的是onclick屬性(這似乎不是必需的),因此您還需要更改它。

window.top.location='something' 

在實際域從這個更改標題鏈接代碼:

<a href="http://worthe.com" onclick="window.location='http://worthe.com'; return false;" class="logo" id="logo-worthe">Worthe Real Estate Group</a> 
<a href="http://mdpa.com" onclick="window.location='http://mdpa.com'; return false;" class="logo" id="logo-mdpa">M. David Paul and Associates</a> 
<a href="http://worthe.com" onclick="window.location='http://worthe.com'; return false;" class="logo" id="logo-krismar">Krismar Construction</a> 

這樣:

<a href="http://worthe.com" onclick="window.top.location='http://worthe.com'; return false;" class="logo" id="logo-worthe" target="_top">Worthe Real Estate Group</a> 
<a href="http://mdpa.com" onclick="window.top.location='http://mdpa.com'; return false;" class="logo" id="logo-mdpa" target="_top">M. David Paul and Associates</a> 
<a href="http://worthe.com" onclick="window.top.location='http://worthe.com'; return false;" class="logo" id="logo-krismar" target="_top">Krismar Construction</a>