【问题标题】:including script doesn't work in web.py包括脚本在 web.py 中不起作用
【发布时间】:2011-09-11 11:29:42
【问题描述】:

大家。我想在 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>

include.js:

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

【问题讨论】:

    标签: javascript python web.py


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2017-08-03
      • 1970-01-01
      • 1970-01-01
      • 2017-08-25
      • 2015-02-21
      • 2012-11-03
      • 2019-01-31
      • 2011-08-10
      • 1970-01-01
      相关资源
      最近更新 更多