如题,登录页面index.html的js代码段如下:jid = form.jid.value;
pass = form.pass.value;
window.open('MainPage.html', makeWindowName(jid),
'width=305,height=590,resizable=yes');
然后在MainPage.html,通过如下代码段获取相关参数if (opener && opener.pass)
pass = opener.pass;
if (opener && opener.jid)
jid = opener.jid;
然后现在需要,不以打开新页面的方式进入MainPage.html页面,就使用了window.location.replace('MainPage.html');
但是问题是,这么之后,jid和pass这两个参数就不知道怎么获取了???
-------
或者,不使用window.location.replace方式,如何才能不以打开新页面方式,使得页面替换为MainPage.html???并使得index.html页面的参数被MainPage.html页面读取到???请教大家了~~谢谢!!javascriptjwchat自动登录

解决方案 »

  1.   

    补充一下,当执行window.location.replace('MainPage.html')后,使用top.XXXX获取不到index.html中的DOM属性值了,这个情况该怎么处理?
      

  2.   

    bbb.html
    <script type="text/javascript">
    window.location.replace('abc.html?jid=123&pass=321');
    </script>abc.html<script type="text/javascript">
    var paras = location.search;
    var result = paras.match(/([^\?&]*=[^&]*)/g);
    var temp;
    paras = {};
    for(var i in result){
    temp = result[i].split('=');
    paras[temp[0]] = temp[1];
    }
    alert(paras.jid);
    alert(paras.pass);
    </script>
      

  3.   


    谢谢,这种方式我试过了,确实可以。但是现在还存在这样一个情况,index.html页面引入了一个config.js配置的文件,这个文件里面填写了很多默认配置属性,如下:
    var BACKENDS = [ {
    name : "Open Relay",
    description : "HTTP Binding backend that allows connecting to any jabber server",
    httpbase : "/JHB/",
    type : "binding",
    default_server : SITENAME
    } ];var DEFAULTRSERVER = "xxx";
    var DEFAULTRESOURCE = "xxxxx";
    var DEFAULTPRIORITY = "10";
    var DEFAULPROJECTNAME="xxxx";要是把这些值全部放到url中,肯定是不太合理的。这个情况该怎么处理呢?我试过在MainPanel.html中引入config.js,但是在页面中获取不到这些值。
      

  4.   


    在MainPanel.html中引入config.js获取不到值?
    这些值跟index.html有什么关系吗?
      

  5.   


    理论上是可以读到,可能是我的调用方式不对。我细细说下,MainPanel.html页面中
    <frameset rows="100%,0,0,0,0" border="0">
    <frame src="<@s.url namespace="/app/wim" action="xxxx!list"/>" name="jwc_main" marginwidth="0" marginheight="0" scrolling="no">
    <frame src="<@s.url namespace="/app/wim" action="xxxx!empty"/>" name="jwc_sound" marginwidth="0" marginheight="0" onLoad="soundLoaded();">
    </frameset>
    action="xxxx!list"对应的是用户列表页面(R.html),之前在这个R.html页面中想获取config.js的值时,直接使用top.XXXX[top.DEFAULTRSERVER],想调用MainPanel.html中的相关方法,直接在按钮上写onClick='return top.openUserInfo(top.cutResource(top.jid))'。现在改用window.location.replace方式之后,top.XXXX提示 缺少对象,top.openUserInfo(top.cutResource(top.jid))对象不支持此属性或方法。这块就不清楚怎么回事了,然后我就在R.html直接引入config.js,依然是上面的异常信息。
    ----
    有的时候,还报出了这样的异常信息 【消息: 不能执行已释放 Script 的代码】,这个是个什么回事?
      

  6.   


    那你在MainPanel.html也声明个window属性.XXXX,jid试下,属性的值为jid=paras.jid(就是传过来那个)。XXXX设置为index.html中的那个值。
      

  7.   


    把这些参数放到MainPanel.html里面,然后在R.html中直调用如openUserInfo(cutResource(jid)),这么是可行的。就是搞不懂为何这时top就用不了。
      

  8.   


    如果你在R.html中引入了config.js就不用top了。top是最顶层WINDOE对象得引用。如果MainPanel不是iframe或者frameset中的frame,那么top就是它了。不用纠结这些鸟东西,问题解决了就可以了。