guozhi
V2EX  ›  问与答

请问如何用 HTML 写一个这样的“框”?

  •  
  •   guozhi · Oct 27, 2015 · 2521 views
    This topic created in 3944 days ago, the information mentioned may be changed or developed.

    代码:

    <form action="http://www.example.com/s" method="get">
        <input type="text" name="wd">
        <input type="submit" value="搜索" />
    </form>
    

    想在这样一个搜索框中加一个固定的参数传递到网址里,例如:

    在文本框中输入 V2EX ,点击搜索按钮就会打开:

    http://www.example.com/s?wd=V2EX&utm_source=XXX

    请问这个 &utm_source=XXX 怎么加进去?谢谢 ^-^

    7 replies    2015-10-27 16:32:20 +08:00
    swuzjb
        1
    swuzjb  
       Oct 27, 2015
    <form action="http://www.example.com/s?utm_source=XXX" method="get">
    <input type="text" name="wd">
    <input type="submit" value="搜索" />
    </form>
    sox
        2
    sox  
       Oct 27, 2015   ❤️ 2
    可惜并不能像楼上这样写,而是

    <input type="hidden" name="utm_source" value="XXX">
    cxbig
        3
    cxbig  
       Oct 27, 2015
    如果这些 SEO 的参数是固定的,用 Input hidden 就好了。
    x86
        4
    x86  
       Oct 27, 2015
    加个隐藏域
    guozhi
        5
    guozhi  
    OP
       Oct 27, 2015
    @sox 谢谢你。谢谢各位!
    guozhi
        6
    guozhi  
    OP
       Oct 27, 2015
    @sox
    @cxbig
    @x86

    再请教大家一个问题,在文本框中输入 1 ,点击按钮就会打开 http://www.example.com/1.png ,如何实现?自己有尝试和搜索但没成功。
    qiayue
        7
    qiayue  
       Oct 27, 2015
    @guozhi 你可以前端拼接或者后端拼接
    前端拼接就是 js 获取输入信息,拼接出完整图片网址,然后打开图片
    后端拼接就是后端获取输入信息,拼接出完整图片地址,然后跳转到图片地址
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2814 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 11:16 · PVG 19:16 · LAX 04:16 · JFK 07:16
    ♥ Do have faith in what you're doing.