使用jQuery重定向页面后,我可以在新页面上填写输入字段吗? [英] After redirecting page using jQuery, can I fill an input field on new page?

查看:102
本文介绍了使用jQuery重定向页面后,我可以在新页面上填写输入字段吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面中放置了jQuery重定向代码.加载页面后,它将在新选项卡上打开一个链接.我想在新标签页上打开的新页面上用"myid1234"填充输入字段. 这可能吗?

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?

这是 fiddle link

推荐答案

不幸的是,你不能!即使您想使用JavaScript注入,例如:

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

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

简单来说,因为您要访问其他URL.如果您要访问的页面确实存在于同一根目录中,则有可能.查看此链接示例以查看有效的示例(请记住允许弹出窗口).

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).

尽管如此,您仍然有机会使其发挥作用.我将通过一个简单的示例向您展示:假设您想使用Google引擎搜索某些内容,而您想执行以下操作:

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>

检查此链接 jsfiddle 以查看有效的示例. 在您的情况下,应将www.google.com/search替换为网站的url操作,即http://www.shopabcfr.com/store/brochures.php. 希望它有用!

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!

这篇关于使用jQuery重定向页面后,我可以在新页面上填写输入字段吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆