js无法向父窗口传值,Untitle.html与a。html可以获取,Untitle。html与ShowPart_interface.jsp无法获取,而a.html的代码就是ShowPart_Interface.jsp运行后产生的html,好难搞,哦 !
Untitled.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language=JavaScript   type=text/JavaScript>
function clickss(){
window.open("http://124.161.95.82:8001/CNC/SearchPartInterface.unicom?partname=运行维护部","tt","width=400,height=300");
//window.open("a.htm","tt","width=400,height=300");
}</script>
<body><form id=f_form name=f_form  method=post ><label>
<input type=text  name=chinaunicom_id />
</label>
<a href="#" onclick="clickss()"> 
555</a></form>
</body>
</html>

解决方案 »

  1.   


    ShowPart_Interface.jsp
    [code=Java]
    <%@ page language="java"pageEncoding="GB2312"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript">
    function clicksk(user_id){
    alert("我要成功阿!我靠!");
    opener.document.f_form.chinaunicom_id.value = user_id;

    window.close();
    }



    function getHttpRequest() {
    var httpRequest = false;
    if (window.XMLHttpRequest) {
    httpRequest = new XMLHttpRequest();
    if (httpRequest.overrideMimeType) {
    httpRequest.overrideMimeType("text/xml");
    }
    } else {
    if (window.ActiveXObject) {
    try {
    httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
    try {
    httpRequest = new ActiveXObject("Microsoft.XMLHTTP ");
    }
    catch (e) {
    }
    }
    }
    }
    return httpRequest;
    }
    var httpReq = new getHttpRequest();
    function searchSuggest() {
    if (httpReq.readyState == 4 || httpReq.readyState == 0) {
    var search = document.getElementById("txtsearch").value;
    if(search==""){
    var ss = document.getElementById("search_suggest");
    ss.style.display="none";

    }else
    {
    var url="SearchNameInterface.unicom?search=" + search;
    httpReq.open("get",url,true);
    httpReq.setRequestHeader( "Content-Type", "text/html;charset=UTF-8" ); 
    httpReq.onreadystatechange = handleSearchSuggest;
    httpReq.send();
    }
    }
    }
      

  2.   

    function handleSearchSuggest() {



    if (httpReq.readyState == 4) {
    var ss = document.getElementById("search_suggest");
    ss.style.display="";
    //清空上次的搜索结果  
    ss.innerHTML="";
    //以"\n"将返回的文本数据分割成数组
    var str = httpReq.responseText.split("\n");


    //循环数据,组织HTML代码
    var suggest="";
    for(var i=0;i<str.length-1;i++){
    var test = str[i].split("|");
    //alert('----'+str[i]);
    suggest += "<div onmouseover='javascript:suggestOver(this);'"
    suggest += " onmouseout='javascript:suggestOut(this);'";
    suggest += " onclick='javascript:setSearch('test[0]');'";
    suggest += " c1ass='suggest_link'>"+str[i]+"</div>";
    }
    suggest += "<div onmouseover='javascript:suggestOver(this);'"
    suggest += " onmouseout='javascript:suggestOut(this);'";
    suggest += " onclick='javascript:closeSearch();'";
    suggest += " c1ass='suggest_link'>关闭</div>";
    alert(suggest);
    ss.innerHTML=suggest;

    }


    }//该方法改变鼠标移动到该选项时的CSS样式表
    var suggestOver = function(div_value){
      div_value.className="suggest_link_over";
    }
    //该方法改变鼠标移出选项时的CSS样式表
    var suggestOut = function(div_value){
    div_value.className="suggest_link";

    }var setSearch = function(str){
        //alert(str.indexOf("&nbsp;"));
    var obj = document.getElementById("txtsearch");
    alert(str);
    obj.value = str;
    var ss =document.getElementById("search_suggest");
    ss.style.display="none";
    }var closeSearch = function(){
    var ss =document.getElementById("search_suggest");
    ss.style.display="none";
    }


    </script>

    <style type="text/css" media="screen">
                       /*设置body样式表*/
                body {
    font:12px arial;
    text-align: center;
    background-image: url(Imgs/left.jpg);
    margin-left: 0px;
    margin-top: 0px;
                }
                /*设置提示连接的样式表*/
                .suggest_link {
    font-size:12px;
                    background-color: #cde5ff;
                    padding: 2px 6px 2px 6px;
                }
                /*设置当鼠标移动到提示上的样式表*/
                .suggest_link_over {
    font-size:12px;
                    background-color: red;
                    padding: 2px 6px 2px 6px;
    }
               /*设置显示搜索提示div的样式表*/
                #search_suggest {
                
                        position: inherit;
                        background-color:#cde5ff;
                        text-align:left; 
    border:0px solid #000000;
    width:300px;
                }
    .div1 { 
    border-left:dashed;
    border-right:dashed;
    border-top:dashed;
    position: absolute;
    top:0px;
    left:0;
        margin:0px auto 0 auto ;
        width:400px;
        height:30px;
       
    overflow:hidden;
    }
    .div2 {
    border-left:dashed; border-bottom:dashed;
     
    position: absolute;
    top:30px;
    left:0px;
        margin:0px auto 0 auto 0px auto 0 auto;
        width:188px;
        height:270px;
        overflow:auto;
    }
    .div3 { 
    border-right:dashed; border-bottom:dashed;
    position: absolute;
    top:30px;
    left:188px;
        margin:0px auto 0 auto;
        width:212px;
        height:270px;
        overflow:auto;
    font-size:12px;
    }
    .div4 { 
    position: absolute;
    top:30px;
    left:50px;
        margin:0px auto 0 auto;
        width:300px;
        overflow:auto;
    }


            .STYLE1 {
    color: #FF0000;
    font-weight: bold;
    }
        </style>
    <LINK REL="StyleSheet" HREF="Manager/dtree.css" TYPE="text/css" />
    <SCRIPT TYPE="text/javascript" >
      

  3.   

    // Node objectfunction Node(id, pid, name, url, title, target, icon, iconOpen, open) { this.id = id; this.pid = pid; this.name = name; this.url = url; this.title = title; this.target = target; this.icon = icon; this.iconOpen = iconOpen; this._io = open || false; this._is = false; this._ls = false; this._hc = false; this._ai = 0; this._p;};// Tree objectfunction dTree(objName) { this.config = { target : null, folderLinks : true, useSelection : true, useCookies : true, useLines : true, useIcons : true, useStatusText : false, closeSameLevel : false, inOrder : false }; this.icon = { root : 'img/base.gif', folder : 'img/folder.gif', folderOpen : 'img/folderopen.gif', node : 'img/page.gif', empty : 'img/empty.gif', line : 'img/line.gif', join : 'img/join.gif', joinBottom : 'img/joinbottom.gif', plus : 'img/plus.gif', plusBottom : 'img/plusbottom.gif', minus : 'img/minus.gif', minusBottom : 'img/minusbottom.gif', nlPlus : 'img/nolines_plus.gif', nlMinus : 'img/nolines_minus.gif' }; this.obj = objName; this.aNodes = []; this.aIndent = []; this.root = new Node(-1); this.selectedNode = null; this.selectedFound = false; this.completed = false;};// Adds a new node to the node arraydTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) { this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);};// Open/close all nodesdTree.prototype.openAll = function() { this.oAll(true);};dTree.prototype.closeAll = function() { this.oAll(false);};// Outputs the tree to the pagedTree.prototype.toString = function() { var str = '<div class="dtree">\n'; if (document.getElementById) { if (this.config.useCookies) this.selectedNode = this.getSelected(); str += this.addNode(this.root); } else str += 'Browser not supported.'; str += '</div>'; if (!this.selectedFound) this.selectedNode = null; this.completed = true; return str;};// Creates the tree structuredTree.prototype.addNode = function(pNode) { var str = ''; var n=0; if (this.config.inOrder) n = pNode._ai; for (n; n<this.aNodes.length; n++) { if (this.aNodes[n].pid == pNode.id) { var cn = this.aNodes[n]; cn._p = pNode; cn._ai = n; this.setCS(cn); if (!cn.target && this.config.target) cn.target = this.config.target; if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id); if (!this.config.folderLinks && cn._hc) cn.url = null; if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) { cn._is = true; this.selectedNode = n; this.selectedFound = true; } str += this.node(cn, n); if (cn._ls) break; } } return str;};// Creates the node icon, url and textdTree.prototype.node = function(node, nodeId) { var str = '<div class="dTreeNode">' + this.indent(node, nodeId); if (this.config.useIcons) { if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node); if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node; if (this.root.id == node.pid) { node.icon = this.icon.root; node.iconOpen = this.icon.root; } str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />'; } if (node.url) {

    str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"'; if (node.title) str += ' title="' + node.title + '"'; if (node.target) str += ' target="' + node.target + '"'; if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" '; if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
    str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"'; str += '>'; } else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id) str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';
    str += node.name; if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>'; str += '</div>';

    if (node._hc) { str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">'; str += this.addNode(node); str += '</div>'; } this.aIndent.pop(); return str;};// Adds the empty and line iconsdTree.prototype.indent = function(node, nodeId) { var str = ''; if (this.root.id != node.pid) { for (var n=0; n<this.aIndent.length; n++) str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />'; (node._ls) ? this.aIndent.push(0) : this.aIndent.push(1); if (node._hc) { str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="'; if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus; else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) ); str += '" alt="" /></a>'; } else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />'; } return str;};
      

  4.   

    代码好长,看得有点晕.把 opener 换成 parent 试下。