guozhi
V2EX  ›  问与答

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

  •  
  •   guozhi · Oct 27, 2015 · 2615 views
    This topic created in 4027 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
    swuzjb
    Oct 27, 2015
    1
    <form action="http://www.example.com/s?utm_source=XXX" method="get">
    <input type="text" name="wd">
    <input type="submit" value="搜索" />
    </form>
    sox
    sox
    Oct 27, 2015❤️2
    2
    可惜并不能像楼上这样写,而是

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

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