2014-12-23 32 views
0

我是一個非常沒有經驗的程序員。我一直在做codeacademy javascript軌道,但我發現你需要把JavaScript放在HTML文件中?我想確保在繼續使用代碼學院之前可以編寫基本的javascript,因此我下載了括號,並且當我嘗試使用實時預覽功能測試我的程序時,它說:「打開一個HTML文件或確保有一個index.html在您的項目文件,以啓動實時預覽。我飛快的打字這件事所以有可能是很多錯誤,但這裏是代碼,是否可以幫助回答我的問題。在Adobe Brackets中打開HTML文件

<!DOCTYPE html> 
<html> 
<body> 

<h1> Daily Programmer Challenge 12/15/14 </h1> 

<script type = "text/javascript"> 

var volume = prompt ("Enter the volume of the container that you wish to make"); 

var cube = math.pow(volume, 1/3); 

window.document.write("The size of the container is '+cube+' width, '+cube+' high, and '+cube+' tall"); 

</script> 
</body> 
</html> 
+0

你也可以把javascript放在另一個單獨的文件中。像test.js – www139

+1

嘗試使用[JSFiddle](http://jsfiddle.net/)先測試你的JavaScript –

+0

@RyanJ:我打算建議他也使用jsfiddle,但是document.write被禁用。 – Academia

回答

1

保存此代碼,您粘貼爲文件名爲index.html,然後嘗試使用Bracket的實時預覽。