Can I POST to a new window that I want to open up?

Can I POST to a new window that I want to open up? - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the Can I POST to a new window that I want to open up? error on your web browser. Problem :


Is this possible?




  1. A third party site is running my Drupal module

  2. An end user clicks on a link which will:

  3. Open up a new window www.mysite.com/redirect.php

  4. and POST certain data to this page www.mysite.com/redirect.php



I've seen the user's browser being redirected, but am not clear on how to do the above.


Solution :

If you just want a link that opens a POST-requested page in a new window here are some ideas. However, be aware a POST request can't be bookmarked.




  • You can make a button that opens a POST-requested page in a new window.



    <form method="post" action="http://example.com/example.php"
    target="_blank">

    <input type="hidden" name="name1" value="value1">
    <input type="hidden" name="name2" value="value2">
    <input type="submit" value="Open results in a new window">
    </form>

  • If you want it to look like a link, you can make a link with an onClick attribute that submits the form.



    <form name="myform" method="post" action="http://example.com/example.php"
    target="_blank">

    <input type="hidden" name="name1" value="value1">
    <input type="hidden" name="name2" value="value2">
    </form>

    <a href="http://example.com/example.php"
    onClick="document.forms['myform'].submit(); return false;">
    Open results
    in a new window</a>


    The onClick part submits the form, which opens the POST-requested page in a new window. The return false prevents the browser from also going to the href address in the current window at the same time. If Javascript is disabled or the link is bookmarked, the href address is used as a fallback, but the resulting page won't receive any POST values. This might be confusing or unfriendly for your users if they bookmark the link.




If you want the link to be bookmarkable, investigate if your page can accept GET parameters. If so, then you can make a bookmarkable link.



 <a href="http://example.com/example.php?name1=value1&name2=value2"
target="_blank">
Open results in a new window</a>

We hope that this article has helped you resolve the html, redirects, drupal error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=