After redirecting page using jQuery, can I fill an

2019-03-02 14:47发布

问题:

I put a jQuery redirect code in a page. After loading the page it opens a link on a new tab. I want to fill an input field with "myid1234" on the new page which is opened on new tab. Is this possible?

here is fiddle link

回答1:

Unfortunately, you can't! Even if you want to use a javascript injection like for example:

javascript:void(document.forms[1].sellerID.value='myid1234');

Simply, because you want to access a different URL. If the page you want to access does exist in the same root, it would be possible. Check this link example to see a working example (Just remember to allow the pop-ups).

Although, you still have one chance to make it work. I'm gonna show you with this simple example: suppose you want to search something with google engine, you wanna do something like this:

<div>
  <form method="GET" action="http://www.google.com/search" target="_blank">
    <label for="search-id">Search</label>
    <input name="q" class="data_field" id="search-id" type="search" placeholder="Introduce your request" />
    <button type='submit'>OK</button>
  </form>
</div>

Check this link jsfiddle to see a working example. In your case you should replace www.google.com/search by the url action of the site, which is http://www.shopabcfr.com/store/brochures.php. Hope it's useful!