web.py 如何设置模板中链接从新窗口打开? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
noah2132

web.py 如何设置模板中链接从新窗口打开?

  •  
  •   noah2132 Jun 26, 2013 4107 views
    This topic created in 4698 days ago, the information mentioned may be changed or developed.
    刚学web.py , 模板中
    <form action="/edit/$x.id" method="post">
    <input type="submit" value="edit" />
    <form>
    要如何做才能在点击“edit”后,在新窗口打开页面呢?
    Supplement 1    Jun 26, 2013
    report.py:

    import web
    import model

    render = web.template.render('templates', base='base')

    urls = (
    '/', 'index',
    '/report/(.*)', 'report'
    )

    class index:
    def GET(self):
    scanlog = model.get_scanlog()
    return render.scanlog(scanlog)

    class report:
    def POST(self, id):
    report = model.get_report(id)
    return render.report(report)

    if __name__ == "__main__":
    app = web.application(urls, globals())
    app.run()
    -----------------------------------------------------------------
    index.html模板:
    $def with (scanlog)
    <table>
    $for x in scanlog
    <tr>
    <form action="/report/$x.ScanID" method="post" tartget="_blank">
    <input type="submit" value="Report" />
    </form>
    </tr>
    </table>
    12 replies    1970-01-01 08:00:00 +08:00
    shiny
        1
    shiny  
    PRO
       Jun 26, 2013   1
    <form action="/edit/$x.id" method="post" target="_blank">
    noah2132
        2
    noah2132  
    OP
       Jun 26, 2013
    添加 target="_blank",先前试过了,不行啊。
    cj1324
        3
    cj1324  
       Jun 26, 2013
    我什么需要在form 中写 target, 这个属性应该写在 a标签中的~
    noah2132
        4
    noah2132  
    OP
       Jun 26, 2013
    @cj1324 form中不是也有这个属性么?
    noah2132
        5
    noah2132  
    OP
       Jun 26, 2013
    @shiny 请问还有没有别的办法?
    cj1324
        6
    cj1324  
       Jun 26, 2013
    form 是一个表单 你需要在表单提交的时候打开一个新的页面 还是在提交成功后打开新页面。
    flyingkid
        7
    flyingkid  
       Jun 26, 2013
    如果还有其他办法的那就是Javascript了。
    cj1324
        8
    cj1324  
       Jun 26, 2013
    有一个叫onSubmit的事件 监听~
    noah2132
        9
    noah2132  
    OP
       Jun 26, 2013
    @cj1324 提交成功后
    qiayue
        10
    qiayue  
    PRO
       Jun 26, 2013
    楼主需求没有描述清楚
    shiny
        11
    shiny  
    PRO
       Jun 26, 2013
    1、这是 HTML,和 web.py 无关
    2、form 里 target="_blank" 我们每天线上在用,如果不能在新窗口中打开,需要自己检查下自己的页面了。
    noah2132
        12
    noah2132  
    OP
       Jun 26, 2013
    代码很简单,index.html页面时列表,点击每行的按钮,生成一个report.html,我就想生成的report.html是在新窗口打开,而不是直接从index.html页面打开。
    About     Help     Advertise     Blog     API     FAQ     Solana     1556 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 35ms UTC 16:34 PVG 00:34 LAX 09:34 JFK 12:34
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86