用window.open()方法打开一个新的窗口,我可以传进自己的变量么? 可以,我才问过这个问题你找weidegong答吧或者到http://www.csdn.net/Expert/TopicView1.asp?id=644393 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 父窗口内容:newwin=window.open("new.htm")<input type=button value="改变新窗口内容" onclick="newwin.pr.innerText='变化了吗'">在new.htm代码如下:<p id=pr>按一下父窗口按钮,这里将有变化</p> 对变量处理的例子父窗口内容:newwin=window.open("new.htm")<input type=button value="新窗口关闭倒计时" onclick="newwin.closewin=true">在new.htm代码如下:<p id=pr>按一下父窗口按钮,这个窗口将关闭</p><script>closewin=false;wait=5;closeMe();function closeMe(){ if (closewin){ pr.innerText="本窗口还有"+wait+"秒将自动关闭" wait--; if (wait<0) window.close(); } setTimeout("closeMe()",100);}</script> 只是一个参数我想模拟手机铃声下载里的那个试听的功能,就是当点击那个“试听”的链接时,window.open()出一个窗口,在这个窗口中播放那个midi!显示,这个midi文件的名称要传到新open的窗口内, 怎么传? <a href=play.jsp?musicname=xy.midi>试听</a> 你在open的窗口里用:window.opener.xxx.value即可 <a href=javascript:window.open('listen/listen.html',null,'toolbar=no,location=no,status=no,menubar=no,width=300,height=100')>TEST</a>点击这个连接后,新窗口是打开了,可是父窗口的地址栏里是:javascript:window.open('listen/listen.html',null,'toolbar=no,location=no,status=no,menubar=no,width=300,height=100')窗口里一片空白,怎么能让你窗口的内容不变呢? 1.如果就传一个参数,可以直接使用第二个参数,如window.open("index2.html","smile","")取参数值,用window.name2.如果再多一点参数,如a=b&c=d,用window.open("index2.html?a=b&c=d","smile","")取参数值,用substr和split解析location.search3.再多一点,先存在原窗口上<input type=hidden name=t value=smile><input type=hidden name=t2 value=laugh>...取参数值,用window.opener.document.all.t.valuewindow.opener.document.all.t2.value等 <a href=# onclick=javascript:window.open('listen/listen.html',null,'toolbar=no,location=no,status=no,menubar=no,width=300,height=100')>TEST</a> 如果用<a href=# onclick=javascript:window.open('listen/listen.html',‘name1’,'toolbar=no,location=no,status=no,menubar=no,width=300,height=100')>TEST</a>来开新窗口,window.name总是匹配不上,为什么呢?而用<a href=javascript:window.open('listen/listen.html',name1,'toolbar=no,location=no,status=no,menubar=no,width=300,height=100')>TEST</a>用window.name却能准确匹配 你说的匹配不上的那个:原因可能是因为,你用了中文的单引号,比较一下:‘name1’<=>'name1' 不是中文单引号的问题只要把<a href=# onclick=javascript:window.open(……)>中的javascript前边的"# onclick="删除,即<a href=javascript:window.open(……)>其它不变就结果就正常! <a href=# onclick=javascript:window.open('listen/listen.html',‘name1’,'toolbar=no,location=no,status=no,menubar=no,width=300,height=100')>TEST</a>中'name1'是常量。而<a href=javascript:window.open('listen/listen.html',name1,'toolbar=no,location=no,status=no,menubar=no,width=300,height=100')>TEST</a>中的name1中变量。当然值不同了,你是不是粗心了点? 这是我往这里输入的手误, 不是我代码的问题!不是中文单引号的问题只要把<a href=# onclick=javascript:window.open(……)>中的javascript前边的"# onclick="删除,即<a href=javascript:window.open(……)>其它不变就结果就正常! 方法有多种:test.htm====================<script>var varStr= "我是Net_lover"window.open("a.htm#" + varStr)</script>a.htm====================<script>function test(){var str2 = window.location.hashalert(str2.substr(1,str2.length))}</script><input onclick="test()" value="单击这里得到传过来的值" type="button"> 没问题呀<a href=# onclick=javascript:window.open('javascript:alert(window.name)','name1','toolbar=no,location=no,status=no,menubar=no,width=300,height=100')>TEST</a> 子窗口可以直接引用父窗口的表单域比方说,父窗口有一隐含域document.form.postValue.value="ddd";子窗口可以直接引用var v=opener.document.form.postValue.value;不需要显式传递 : qiushuiwuhen(秋水无恨) 你的这个说法欠妥:2.如果再多一点参数,如a=b&c=d,用window.open("index2.html?a=b&c=d","smile","")取参数值,用substr和split解析location.searchwindow.open("index2.html?a=b&c=d"……)以这种方面传进去的参数不需要substr和split解析location.search,简单的问题被你复杂化了!!!这种方式传进去的参数和用<a href=……>方式传进去的参数是一样的,在php里直接使用,用不着什么解析! 求JSP代码 正则表达式 这个函数是神马意思? My97DatePicker 浏览器兼容问题 如何点击某链接后,使该连接的class改变 代码$('table tr:even').addClass('even');我自己的意思是把偶数行加个even类(效果是蓝色背景),效果果却加到了奇数行 请问怎么用javascript通过搜索注册表以判断一个软件是否安装 js脚本解密 访问object标签里面的内容? 有没有现成的函数判断从表单获得的字符串是不是一个合法的日期? 怎样实现跳转同时刷新目的页面的功能? INPUT BOX里怎麼樣才能動態知道該內容已經變更?
newwin=window.open("new.htm")
<input type=button value="改变新窗口内容" onclick="newwin.pr.innerText='变化了吗'">在new.htm代码如下:
<p id=pr>按一下父窗口按钮,这里将有变化</p>
父窗口内容:
newwin=window.open("new.htm")
<input type=button value="新窗口关闭倒计时" onclick="newwin.closewin=true">在new.htm代码如下:
<p id=pr>按一下父窗口按钮,这个窗口将关闭</p>
<script>
closewin=false;
wait=5;
closeMe();
function closeMe(){
if (closewin){
pr.innerText="本窗口还有"+wait+"秒将自动关闭"
wait--;
if (wait<0) window.close();
}
setTimeout("closeMe()",100);
}
</script>
我想模拟手机铃声下载里的那个试听的功能,就是当点击那个“试听”的链接时,
window.open()出一个窗口,在这个窗口中播放那个midi!显示,这个midi文件的名称要传到新open的窗口内, 怎么传?
window.opener.xxx.value即可
javascript:window.open('listen/listen.html',null,'toolbar=no,location=no,status=no,menubar=no,width=300,height=100')
窗口里一片空白,怎么能让你窗口的内容不变呢?
window.open("index2.html","smile","")
取参数值,用window.name2.如果再多一点参数,如a=b&c=d,用
window.open("index2.html?a=b&c=d","smile","")
取参数值,用substr和split解析location.search3.再多一点,先存在原窗口上
<input type=hidden name=t value=smile>
<input type=hidden name=t2 value=laugh>
...
取参数值,用window.opener.document.all.t.value
window.opener.document.all.t2.value等
用window.name却能准确匹配
‘name1’<=>'name1'
只要把<a href=# onclick=javascript:window.open(……)>中的javascript前边的"# onclick="删除,即<a href=javascript:window.open(……)>其它不变就结果就正常!
而<a href=javascript:window.open('listen/listen.html',name1,'toolbar=no,location=no,status=no,menubar=no,width=300,height=100')>TEST</a>中的name1中变量。
当然值不同了,你是不是粗心了点?
不是中文单引号的问题
只要把<a href=# onclick=javascript:window.open(……)>中的javascript前边的"# onclick="删除,即<a href=javascript:window.open(……)>其它不变就结果就正常!
test.htm
====================
<script>
var varStr= "我是Net_lover"
window.open("a.htm#" + varStr)
</script>a.htm
====================
<script>
function test(){
var str2 = window.location.hash
alert(str2.substr(1,str2.length))
}
</script>
<input onclick="test()" value="单击这里得到传过来的值" type="button">
比方说,父窗口有一隐含域document.form.postValue.value="ddd";
子窗口可以直接引用
var v=opener.document.form.postValue.value;
不需要显式传递
2.如果再多一点参数,如a=b&c=d,用
window.open("index2.html?a=b&c=d","smile","")
取参数值,用substr和split解析location.searchwindow.open("index2.html?a=b&c=d"……)以这种方面传进去的参数不需要substr和split解析location.search,简单的问题被你复杂化了!!!
这种方式传进去的参数和用<a href=……>方式传进去的参数是一样的,在php里直接使用,用不着什么解析!