3
我開始在Opera中學習UserJS。爲了測試,我試圖連接jQuery庫和jQuery UI,但它不起作用。這裏是代碼:Opera中的jQuery用戶jS
(function() {
var headID = document.getElementsByTagName("head")[0];
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.id = 'myjQuery';
newScript.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';
headID.appendChild(newScript);
newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.id = 'myjQuery2';
newScript.src = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js';
headID.appendChild(newScript);
alert('first alert');
window.addEventListener('load', function (e) {
$('body').html('test page');
}, false);
})();
第一警報工作。兩個庫連接到頁面,但jQuery代碼不起作用。哪裏不對?
PS。我收到一個錯誤:ReferenceError:Undefined variable:$
我想這一點,但沒有奏效。你確定這個選項有效嗎? – Anton 2012-01-14 12:56:00
我正在寫Opera擴展。這是你的擴展方法,它沒有工作:http://dl.dropbox.com/u/30086473/HabraCorrector.oex – Anton 2012-01-14 12:58:31
請看看,並告訴我有什麼問題 – Anton 2012-01-14 12:58:52