2017-04-03 26 views
5

我想停止了window.location的執行如下加載網頁時:停止執行window.location的在全球範圍內

<script type="text/javascript"> 
alert('Bid closed '); 
window.location = '/index.html'; 
</script> 

我能夠通過更換alert功能時document_start在繞過alert消息manifest.json。但無法停止window.location執行。

+0

警覺根據病情? –

+0

當然不是。 – user5858

回答

0

答案在我看來就像一個數學難題。

在注入腳本我剛剛放在這個代碼,它似乎工作:

window.alert = 
       function (msg) 
        { 
         throw Error('hello'); 
        } 

此異常導致瀏覽器跳到下一個語句window.location=

+0

對於這個問題的答案,請在問題中明確指出您希望停止執行* exact *代碼。目前這個問題通常是如何停止設置'window.location'的執行。不知道你想停止那個*精確的*代碼,這似乎並沒有真正回答這個問題。 – Makyen

+0

@Makyen這是我所問的解決方案。我用我在問題中提出的代碼進行了測試。 – user5858

2

window對象不是可寫的,所以你不能改變documentwindow對象 檢查這個link更多信息