2016-02-19 62 views
0

我試圖從Browser-Update.org項目實現腳本,該項目檢查瀏覽器版本並提示用戶在使用舊版本時進行更新。 It can be found here.Browser-Update.org定製

在他們customization documentation,它們允許你顯示的信息欄時執行的javascript:

onshow: function(infos){},  // callback function after the bar has appeared 

我想不通的地方在他們的腳本插入此。我想運行下面的JavaScript時OnShow中被觸發:

document.getElementById('Submit').disabled = true; 

以下是我已經嘗試過失敗:

<script> 
var $buoop = {c:2}; 

function $buo_f(){ 
var e = document.createElement("script"); 
e.src = "//browser-update.org/update.min.js"; 
document.body.appendChild(e); 

}; 
try {document.addEventListener("DOMContentLoaded", $buo_f,false)} 
catch(e){window.attachEvent("onload", $buo_f)} 

onshow: function(infos){ 
    document.getElementById('Submit').disabled = true; 
}; 

</script> 

我是一個真正的JavaScript的新手,我失去了對這個。謝謝。 -Brian

+1

您是否嘗試將函數中的代碼? – j08691

回答

1

這是一種方式:

onshow: function(infos){ 
    document.getElementById('Submit').disabled = true; 
},  // callback function after the bar has appeared 

你也可以打電話內的一個功能。

如果您選擇將它全部保留在那裏,這將是完整的塊。

<script> 
var $buoop = { 
    vs: {i:6,f:2,o:9.63,s:2,c:10}, // browser versions to notify 
    reminder: 24,     // atfer how many hours should the message reappear 
           // 0 = show all the time 
    reminderClosed: 150    // if the user closes message it reappears after x hours 
    onshow: function(infos){ 
     document.getElementById('Submit').disabled = true; 
    },  // callback function after the bar has appeared 
    onclick: function(infos){},  // callback function if bar was clicked 
    onclose: function(infos){},  // 

    l: false,      // set a language for the message, e.g. "en" 
           // overrides the default detection 
    test: false,     // true = always show the bar (for testing) 
    text: "",      // custom notification html text 
           // Optionally include up to two placeholders "%s" which will be replaced with the browser version and contents of the link tag. Example: "Your browser (%s) is old. Please <a%s>update</a>" 
    text_xx: "",     // custom notification text for language "xx" 
           // e.g. text_de for german and text_it for italian 
    newwindow: true     // open link in new window/tab 
    url: null      // the url to go to after clicking the notification 
}; 

function $buo_f(){ 
var e = document.createElement("script"); 
e.src = "//browser-update.org/update.min.js"; 
document.body.appendChild(e); 

}; 
try {document.addEventListener("DOMContentLoaded", $buo_f,false)} 
catch(e){window.attachEvent("onload", $buo_f)} 

</script> 
+0

這應該如何放置在我的實際腳本中?我用我的代碼示例更新了我的問題。 –

+0

編輯我的答案。這就是您可以完全自定義庫的方式。如果您認爲合適,您可以更多地添加/刪除選項,但是我沒有對它進行測試,因此我繼續向他們投放他們的示例,而不僅僅是包括onshow! – javajavajava