为什么这不起作用? [英] Why is this not working?
问题描述
打开一个新窗口window_1,其中包含一个表单,使用窗口
引用更改值并提交,任何人都可以快速
glimse over this br / >
windows打开确定,之后没有任何反应:(
var window_1; //全局值
function function_1(){
window_1 = window.open(''http // ...'');
setTimeout(function_2,10000); // 10秒加载
}
函数function_2()
{
window_1.forms [''postform'']。 elements [''commenttext'']。value =''test'';
window_1.forms [''postform'']。submit();
}
function_1在打开的窗口中的body onload中调用
opens a new window window_1 which contains a form, uses window
reference to change values there and submits, anyone can have a quick
glimse over this
windows opens ok, nothing happens afterwards : (
var window_1; // global value
function function_1() {
window_1 = window.open(''http//...'');
setTimeout(function_2, 10000); // 10 secs to load
}
function function_2()
{
window_1.forms[''postform''].elements[''commenttext''].value = ''test'';
window_1.forms[''postform''].submit();
}
function_1 is called in body onload in the opened window
推荐答案
4月6日, 2:37 pm,Mikhail Kovalev< mikhail_kova ... @ mail.ruwrote:
On Apr 6, 2:37 pm, "Mikhail Kovalev" <mikhail_kova...@mail.ruwrote:
打开一个新窗口window_1,其中包含一个表单,使用窗口
引用更改值并提交,任何人都可以快速
glimse over this
windows打开确定,没有事后发生:(
var window_1; //全球价值
函数function_1(){
window_1 = window.open(''http // ...'');
setTimeout(function_2,10000); // 10秒钟加载
}
函数function_2()
{
window_1.forms [''postform'']。elements [''commenttext'']。value =''test'';
window_1.forms [''postform'']。submit ();
}
function_1在打开的窗口中的body onload中被调用
opens a new window window_1 which contains a form, uses window
reference to change values there and submits, anyone can have a quick
glimse over this
windows opens ok, nothing happens afterwards : (
var window_1; // global value
function function_1() {
window_1 = window.open(''http//...'');
setTimeout(function_2, 10000); // 10 secs to load
}
function function_2()
{
window_1.forms[''postform''].elements[''commenttext''].value = ''test'';
window_1.forms[''postform''].submit();
}
function_1 is called in body onload in the opened window
i认为当你在做setTimeout()时你必须把代码放在
引号中,所以它应该是:
setTimeout(" function_2( )",10000);
和在function_2中我认为你想做winow_1.document.forms而不是
比window_1.forms
i think when you''re doing setTimeout() you have to put the code in
quotes, so it should be:
setTimeout("function_2()", 10000);
and in function_2 i think you want to do winow_1.document.forms rather
than window_1.forms
br ******** ****@gmail.com 在2007年4月6日下午2:59发表以下内容:
br************@gmail.com said the following on 4/6/2007 2:59 PM:
4月6日下午2:37 ,Mikhail Kovalev, < mikhail_kova ... @ mail.ruwrote:
On Apr 6, 2:37 pm, "Mikhail Kovalev" <mikhail_kova...@mail.ruwrote:
>打开一个新窗口window_1,其中包含一个表单,使用窗口
引用来更改那里的值并提交,任何人都可以快速浏览这个
窗口打开确定,之后没有任何事情发生:(
var window_1; //全球价值
> function function_1(){
window_1 = window.open(''http // ...'');
setTimeout(function_2,10000); // 10秒加载
}
函数function_2()
{
window_1.forms [''postform'']。elements [''commenttext'']。value =''test '';
window_1.forms [''postform'']。submit();
在打开的窗口中在body onload中调用function_1 b $ b
>opens a new window window_1 which contains a form, uses window
reference to change values there and submits, anyone can have a quick
glimse over this
windows opens ok, nothing happens afterwards : (
var window_1; // global value
function function_1() {
window_1 = window.open(''http//...'');
setTimeout(function_2, 10000); // 10 secs to load
}
function function_2()
{
window_1.forms[''postform''].elements[''commenttext''].value = ''test'';
window_1.forms[''postform''].submit();
}
function_1 is called in body onload in the opened window
i想你在做setTimeout()时你必须把代码放在
引号中,所以它应该是:
setTimeout(" function_2()",10000);
i think when you''re doing setTimeout() you have to put the code in
quotes, so it should be:
setTimeout("function_2()", 10000);
很容易测试是否应该引用它。在您选择的浏览器中尝试这个
代码:
window.onload = testIt;
function testIt(){
window.setTimeout(myFunction,1000)
window.setTimeout(''myFunction2()'',2000)
}
function myFunction(){
alert(''没有引用'')
}
函数myFunction2(){
alert(''引用'')
}
It is very easy to test whether it should be quoted or not. Try this
code in the browser of your choice:
window.onload=testIt;
function testIt(){
window.setTimeout(myFunction,1000)
window.setTimeout(''myFunction2()'',2000)
}
function myFunction(){
alert(''no quotes used'')
}
function myFunction2(){
alert(''quotes used'')
}
和在function_2中我认为你想做winow_1.document。表格相比
比window_1.forms
and in function_2 i think you want to do winow_1.document.forms rather
than window_1.forms
可能,但window_1.document.forms可能比winow_1更好..
-
兰迪
机会有利于预备心灵
comp.lang.javascript常见问题 - http://jibbering.com/faq/index.html
Javascript最佳实践 - http://www.JavascriptToolbox.com/bestpractices/
谢谢你们,无论如何我认为它出来,脚本不工作bc of
跨站点脚本限制
新窗口我打开的是另一个域
但是它尝试了一个类似的方法,在两个分割框架中使用相同的网站
窗口,它可以在Safari 1.3.2中使用
http://pastebin.se/12827
可能是safari中的安全漏洞
4月7日,00:55,Randy Webb< HikksNotAtH ... @ aol.comwrote:
Thanks guys, anyway I figured it out , the script doesnt work bc of
cross site scripting restrictons
The new window Im opening is on another domain
However it tried a similar method with same site in two-split frame
window, and it works in Safari 1.3.2
http://pastebin.se/12827
Could be a security flaw in safari
On 7 Apr, 00:55, Randy Webb <HikksNotAtH...@aol.comwrote:
brunascle.m ... @ gmail .com在2007年4月6日下午2:59说了以下内容:
brunascle.m...@gmail.com said the following on 4/6/2007 2:59 PM:
4月6日下午2:37,Mikhail Kovalev < mikhail_kova ... @ mail.ruwrote:
On Apr 6, 2:37 pm, "Mikhail Kovalev" <mikhail_kova...@mail.ruwrote:
打开一个新窗口window_1,其中包含一个表单,使用窗口
引用更改那里的值和提交,任何人都可以快速
glimse这个
windows打开确定,之后没有任何事情发生:(
opens a new window window_1 which contains a form, uses window
reference to change values there and submits, anyone can have a quick
glimse over this
windows opens ok, nothing happens afterwards : (
var window_1; //全局值
var window_1; // global value
函数function_1(){
window_1 = window.open(''http // ...'');
setTimeout( function_2,10000); // 10秒加载
function function_1() {
window_1 = window.open(''http//...'');
setTimeout(function_2, 10000); // 10 secs to load
}
}
function function_2()
{
window_1.forms [ '' postfor m'']。elements [''commenttext'']。value =''test'';
window_1.forms [''postform'']。submit();
function function_2()
{
window_1.forms[''postform''].elements[''commenttext''].value = ''test'';
window_1.forms[''postform''].submit();
}
}
function_1在打开的窗口中的body onload中被调用
function_1 is called in body onload in the opened window
i think当你在做setTimeout()时你必须把代码放在
引号中,所以它应该是:
setTimeout(" function_2()",10000 );
i think when you''re doing setTimeout() you have to put the code in
quotes, so it should be:
setTimeout("function_2()", 10000);
测试是否应该引用是非常容易的。在你选择的浏览器中试试这个
代码:
window.onload = testIt;
function testIt(){
window.setTimeout(myFunction,1000)
window.setTimeout(''myFunction2()'',2000)}
function myFunction(){
alert(''没有引用'')}
函数myFunction2(){
alert (''引用'')
}
It is very easy to test whether it should be quoted or not. Try this
code in the browser of your choice:
window.onload=testIt;
function testIt(){
window.setTimeout(myFunction,1000)
window.setTimeout(''myFunction2()'',2000)}
function myFunction(){
alert(''no quotes used'')}
function myFunction2(){
alert(''quotes used'')
}
和在function_2中我认为你想做winow_1.document。表格相比
比window_1.forms
and in function_2 i think you want to do winow_1.document.forms rather
than window_1.forms
可能,但window_1.document.forms可能比winow_1更好..
-
兰迪
机会有利于预备心灵
comp.lang.javascript常见问题-http:// jibbering.com/faq/index.html
Javascript最佳实践-http://www.JavascriptToolbox.com/bestpractices/
Possibly, but window_1.document.forms might work better than winow_1..
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
这篇关于为什么这不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!