我想知道如何將JavaScript文件中的變量值傳遞到寫入HTML文件頂部的腳本函數中的變量。將變量值傳遞給腳本函數中的變量(Javascript)
我寫的是這樣的:
myjsfile.js:
var abc = "10";
HTML文件:
<html>
<head>
<script type="text/javascript">
(function() {
var test = document.createElement('script'); test.type = 'text/javascript'; test.async = true;
test.src = 'testquery.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(test, s);
alert(abc);
})();
</script>
</head>
<body>
</body>
</html>
我沒有得到的輸出。請幫忙!提前致謝。
基本上我試圖創建一個jquery插件就像谷歌分析。
test.onload = function(){alert(abc);}代碼爲我工作....但如何顯示圖像存儲在外部jquery – Christina 2012-07-12 07:07:56