Submit webform via URL only?

前端 未结 2 953
小鲜肉
小鲜肉 2021-01-13 17:39

I\'m not really sure this belongs here, so instead of downvoting just lemme know if so and I\'ll quickly move it on.

Anyway, there is a website that has a search pag

相关标签:
2条回答
  • 2021-01-13 18:13

    Sometimes servers conflate GET and POST parameters, as in PHP $_REQUEST hash. However, normally they are separate - and a server that expects its parameters in multipart/form-data might not look at URL at all. In such a case, as it seems to be here, you have to construct a POST request. On the client side you can do it through AJAX or through constructing and posting a form; on the server side, you can use curl, or a library. You did not say what you want to use it for (and where you want to use it), so you just get the general answer, I'm afraid.

    EDIT: Here is the JavaScript semi-solution. You have to already be on some page (i.e. can't use it on _blank), and I'm not sure if it works on all browsers.

    javascript:d=document;f=d.createElement("form");h=d.createElement("input");f.setAttribute("method","post");f.setAttribute("enctype","application/x-www-form-urlencoded");f.setAttribute("action","http://www.torec.net/ssearch.asp");h.setAttribute("type","hidden");h.setAttribute("name","search");h.setAttribute("value","query");f.appendChild(h);d.body.appendChild(f);f.submit();
    
    0 讨论(0)
  • 2021-01-13 18:27

    Edit: It is not possible to create a link directly to the first page. However, you can easily send a user to the first page by by creating a form:

    <form id="postForm" method="post" action="http://www.example.com/search">
        <input type="text" name="search" value="q">
    </form>
    

    And then submitting the form whenever the user clicks a psuedo-link:

    document.getElementById("postForm").submit();
    

    This can also be done by typing JavaScript code into the address bar:

    javascript:a=document.createElement("form");a.method="POST";a.action="http://www.torec.net/‌​ssearch.asp?search=dark&page=2";i=document.createElement("input");i.name="search";i.value="q";a.appendChild(inpu‌​t);a.submit();

    0 讨论(0)
提交回复
热议问题