javascript函数的参数可以是页面元素吗? 本帖最后由 xiaosong2008 于 2013-08-30 11:32:08 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 试试:window.opener.form1.textBox.value= " \/UserFiles\/images\/" + value1; textBox对应图片文本框Id,我怀疑你的id 是.net下的id 之前就是这样写的,同样的错误提示!这样写textBox是<input的name 之前就是这样写的,同样的错误提示!这样写textBox是<input的name是的,这样写的方法是获取html下的表单元素,而这里的表单元素是.net控件 你的textBox是什么?是name字符串的话window.opener.form1[textBox].value= " \/UserFiles\/images\/" + value1;是id字符串的话window.opener.document.getElementById(textBox).value= " \/UserFiles\/images\/" + value1;是dom元素对象的话textBox.value= " \/UserFiles\/images\/" + value1; 谢谢各位的帮助,将函数改成如下: <script> function res(textBox,value1) { window.opener.form1[textBox].value= " \/UserFiles\/images\/" + value1; window.close(); } </script>调用成功了呵呵,如果我想将asp.net页面的中表单控件也作为参数,该如何写呢?将函数改成如下: <script> function res(form,textBox,value1) { window.opener.form[textBox].value= " \/UserFiles\/images\/" + value1; window.close(); } </script>或者如下: <script> function res(form,textBox,value1) { window.opener.document.getElementById[form][textBox].value= " \/UserFiles\/images\/" + value1; window.close(); } </script>均不行,提示找不到无法获取属性“TextBox1”(参数textBox调用的值)的值: 对象为 null 或未定义请大家继续帮忙看看,呵呵,谢谢了! window.opener.forms[form][textBox].value= " \/UserFiles\/images\/" + value1; 谢谢各位的帮助,将函数改成如下: <script> function res(form,textBox,value1) { window.opener.document.forms[form][textBox].value= " \/UserFiles\/images\/" + value1; window.close(); } </script>问题解决了 chrome扩展,如何获得当前页面的指定元素值? 急急急 extjs中文url中文参数乱码 深经半夜发帖求助,如何禁止子窗口刷新父窗口?详情请进>> 字符串的查找与替换 急~ 论坛引用功能 关于for…in语句代码 怎样取每一行里的值? 请教一个很急的javacript问题!!!救火!!! 啊。。写了一天了。。ASP和DHTML结合的远程调用的简化,仿WebService做的。 请问window.onbeforeunload与$(window).unload区别 js里面动态绑定按钮单击事件 散分了!发个自己写的jquery+表格颜色变化
window.opener.form1.textBox.value= " \/UserFiles\/images\/" + value1;
之前就是这样写的,同样的错误提示!这样写textBox是<input的name
之前就是这样写的,同样的错误提示!这样写textBox是<input的name是的,这样写的方法是获取html下的表单元素,而这里的表单元素是.net控件
window.opener.form1[textBox].value= " \/UserFiles\/images\/" + value1;是id字符串的话
window.opener.document.getElementById(textBox).value= " \/UserFiles\/images\/" + value1;是dom元素对象的话
textBox.value= " \/UserFiles\/images\/" + value1;
<script>
function res(textBox,value1)
{
window.opener.form1[textBox].value= " \/UserFiles\/images\/" + value1;
window.close();
}
</script>
调用成功了呵呵,如果我想将asp.net页面的中表单控件也作为参数,该如何写呢?
将函数改成如下:
<script>
function res(form,textBox,value1)
{
window.opener.form[textBox].value= " \/UserFiles\/images\/" + value1;
window.close();
}
</script>
或者如下:
<script>
function res(form,textBox,value1)
{
window.opener.document.getElementById[form][textBox].value= " \/UserFiles\/images\/" + value1;
window.close();
}
</script>
均不行,提示找不到无法获取属性“TextBox1”(参数textBox调用的值)的值: 对象为 null 或未定义请大家继续帮忙看看,呵呵,谢谢了!
<script>
function res(form,textBox,value1)
{
window.opener.document.forms[form][textBox].value= " \/UserFiles\/images\/" + value1;
window.close();
}
</script>
问题解决了