2011-06-09 69 views
0
工作

大家都是想在HTML(webpy模板)的JavaScript,但它並不work.the在html javascript代碼工作得非常好......包括腳本不web.py

以下是主要蟒文件(main.py):

urls = ('/main','main') 
render = web.template.render('templates/') 

class main: 
    def GET(self): 
    return render.main() 

app = web.application(urls,globals()) 

if __name__ == "__main__": 
    app.run() 

模板/ main.htm中:

<body> 
<script type="text/javascript" src="include.js"></script> 
<script> 
    alert(location.href); //this line works.. 
</script> 
</body> 

include.js:

alert('test'); //this line doesn't work 

回答

3

您必須將include.js文件放在項目根目錄下的「static/js」目錄中,並且src應該是「static/js/include.js」。

+0

它現在的作品,非常感謝你! – 2011-06-09 07:42:22