Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4114678
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:29:09+00:00 2026-05-20T22:29:09+00:00

I have a form that lets users select checks, and when submitted, creates a

  • 0

I have a form that lets users select checks, and when submitted, creates a PDF, which opens in a new browser tab. It doesn’t have any branding, and will probably open in a plugin anyway, so I don’t want it taking over my site’s tab. So I set the form’s target to _blank.

But it’s possible for the user to submit the form without enough information to create the PDF, in which case I flag the error (server-side) and re-render the form. But because I set the form’s target, this re-render opens in a new tab as well, and that’s not what I want – in this case, I want it to behave as if target were _top.

So the question is: Can I change the browser’s rendering target server-side?

Yes, I know that this can be done with client-side JavaScript, but JS annoys me, and I have to do the validation server-side anyway. I may end up having to use it, but please don’t suggest it as an answer – I’m more curious if what I’m attempting can even be done.

PS: I’m on Ruby on Rails 2.3.8, in case anyone knows a framework-specific solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:29:09+00:00Added an answer on May 20, 2026 at 10:29 pm

    No. This is a purely client-specific feature. As a matter of fact, it’s quite possible to get a browser that supports only one window and where the target attribute would have simply no effect. There were even efforts to make this attribute disappear from future HTML standards completely (for instance, the XHTML branch had no such attribute).

    The only overlap that I can think of between HTML and HTTP are the <meta http-equiv> tags (where HTML can affect otherwise HTTP-controlled behavior). HTTP is a transfer protocol, designed to work with about just any kind of data. Letting it control presentation would be a pretty terrible mix of concerns.

    Fortunately, we live in a JavaScript-enabled world. It is rather easy to validate a form using an AJAX request, especially with libraries like jQuery.

    For instance, this script performs a POST request to an URL (in this case, /pdf/validate) and expects the page to send back “ok” (if everything’s good) or something else if there was an error.

    <form method="post" action="/pdf/send" id="pdf-form">
        <!-- form stuff here -->
    </form>
    
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function()
    {
        // set to true if we are to bypass the check
        // this will happen once we've confirmed the parameters are okay
        var programmaticSubmit = false;
    
        // attach an event handler for when the form is submitted
        // this allows us to perform our own checks beforehand; we'll do so by
        // cancelling the event the user triggered, and do the submit ourselves if
        // we detect no error
        $('#pdf-form').submit(function(event)
        {
            if (!programmaticSubmit)
            {
                // first off, cancel the event
                event.preventDefault();
    
                // do an AJAX request to /pdf/validate
                $.ajax("/pdf/validate", {
                    type: "POST",
                    data: $(this).serialize(),  // send the form data as POST data
                    success: function(result)
                    {
                        // this gets called if the HTTP request did not end
                        // abnormally (i.e. no 4xx or 5xx status);
                        // you may also want to specify an "error" function to
                        // handle such cases
                        if (result == "ok")
                        {
                            // since the server says the data is okay, we trigger
                            // the event again by ourselves, but bypassing the
                            // checks this time
                            programmaticSubmit = true;
                            $(this).submit();
                        }
                        else // something went wrong! somehow display the error
                            alert(result);
                    }
                });
            }
        });
    });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an admin form that lets users create entities that require an image.
I have a form that contains a GridView control which is databound to an
I have an Access Form - lets call it Add Labor (Access 2007) that
I have a form that lets a user perform a search for a stock
I have a form that lets the user enter in some text. It will
I have a zend form that lets the user fill out attributes of an
I have a form that lets the user to either add an employee's details
Let's say you have a form with a component that displays data from a
Let's say I have a multithreaded C++ program that handles requests in the form
I have form that displays several keywords (standard set of choice lists that changes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.