我是相当新的程序员,我需要一个建议我怎么能做到这一点,瞄准输入框在外部网页
我的目标是能够在例如新窗口中打开一个新的网站google.com并在搜索输入框中输入一个字符串,而无需用户执行任何操作。
我看了很多想法,这将如何实施,但似乎没有找到我可以使用的解决方案。
我做了一个按钮,触发此javascript函数:
function OpenPopupCenter() {
pageURL = 'http://www.google.com';
title = 'temp title';
w = (window.outerWidth * 0.67);
h = (window.outerHeight * 0.80);
var dualScreenLeft = typeof window.screenLeft !== "undefined" ? window.screenLeft : screen.left;
var dualScreenTop = typeof window.screenTop !== "undefined" ? window.screenTop : screen.top;
var width = window.innerWidth ? window.innerWidth :
document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
var height = window.innerHeight ? window.innerHeight :
document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
var left = ((width/2) - (w/2)) + dualScreenLeft -125;
var top = ((height/2) - (h/2)) + dualScreenTop;
var newWindow = window.open(pageURL, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
$(newWindow).ready(function() {
$("#lst-ib").val("Hello World");
});
的窗口打开显示谷歌,但我无法目标由ID LST-IB和插入字符串“Hello World输入框中“进入它,我做错了,任何人都可以指导我找到正确的解决方案,或者想出一个可行的解决方案。
这听起来像是一项违反JavaScript跨域策略的任务,因此可能无法实现。请记住,一个可以控制另一个网站的网站可以访问诸如银行信息或电子邮件等敏感内容。也许在网站“Let Me Google That For You”中看到的“假”收购可以激发你的需求? –