0

大家。我想在 html(webpy 模板)中包含 javascript,但它不起作用。html 中的 javascript 代码运行良好......

以下是主要的python文件(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>

包括.js:

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

1 回答 1

3

您必须将include.js文件放在项目根目录下的“static/js”目录中,并且src应该是“static/js/include.js”。

于 2011-06-09T07:36:17.353 回答