第一问的答案: <script language="JavaScript"> function toquery() { var tmpstr=unescape(window.location.toString()); var tmp=tmpstr.indexOf('?') tmpstr=tmpstr.substring(tmp+1,tmpstr.length); var strs=tmpstr.split('&'); for (var i=0;i<strs.length;i++) eval(strs[i]+";"); } toquery(); </script> 如果是url="winurl.htm?a="+a+"&b="+b,在JavaScript中就可以用变量a和b了。
第一问的答案:
<script language="JavaScript">
function toquery()
{
var tmpstr=unescape(window.location.toString());
var tmp=tmpstr.indexOf('?')
tmpstr=tmpstr.substring(tmp+1,tmpstr.length);
var strs=tmpstr.split('&');
for (var i=0;i<strs.length;i++) eval(strs[i]+";");
}
toquery();
</script>
如果是url="winurl.htm?a="+a+"&b="+b,在JavaScript中就可以用变量a和b了。
我能直接用变量吗,我是在脚本中用。我该怎么用
url="winurl.htm?a="+a+"&b="+b
传出来可能就是winurl.htm?a=123&b=456通过它的循环
eval(strs[i]+";");就会是
eval("a=123;");
eval("b=456;");从而实现类似
<script>
a=123;
b=456;
</script>
的效果!你应该看看书了!你没有javascript的帮助文件嘛?
varstr="这是传到sub.htm的值";
retvar=window.showModalDialog("sub.htm",varstr,"width=200;height=90");2、sub.htm从main.htm接收变量值
mainvar=window.dialogArguments;
alert(mainvar);3、sub.htm返回变量值给main.htmwindow.returnValue="这是从sub.htm中返回的变量值";4、在main.htm中判断有无返回值。if (retvar!=null)alert(retvar);
split是javascript 中字符传的function吗?有否相关的电子书,再次谢谢!
邮箱!
http://192.168.1.35/iFocus.htm?b=328324我用unescape(window.location.toString()); 怎么只得到?b=328324
我要前面的192.168.1.35该怎么办?
多谢指点!
window.location.hostname 就可以啦。
结分啦!