可以用cookie,不过这个最好是用后台的语言弄

解决方案 »

  1.   

    var win=window.open ('rhistogram.html','newwindow1','height=500,width=256,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')
    win.打开页面的方法(参数)
    win就是打开的页面的句柄,你要传递内容,打开页面提供一个函数更新直方图,父页通过win调用那个方法
      

  2.   

    rhistogram.html?id=id可以这样传值的,取值的话,就使用location就可以了。。比如取出问号之后的值,
    location.search就是,结果就是?id=id,应该就是这样的,之后再把这个字符串处理,取出自己想要的部分就行了。试试看,如果有问题,可以查下location对象。
    没有测试。
      

  3.   

    function rhistogram(){
    var handle = window.open ('rhistogram.html','newwindow1','height=500,width=256,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no') 
        handle.rhistogram(r);
    }//这个是我的父页的代码
    function rhistogram(r){
    var canvas=document.getElementById("canvas");
        var ctx =canvas.getContext('2d');
        var imgdata = ctx.getImageData(0,0,canvas.width,canvas.height);
        var pixTotal = imgdata.height*imgdata.width;
        for(var i=0;i<imgdata.width;i++){
        for(var j=0;j<imgdata.width;j++){
        imgdata.data[(j*imgdata.width+i)*4] = r[j*imgdata.width+i];
              }
           }
        var pixCount = [];  
        for(var i=0;i<256;i++) pixCount[i]=0;  
        for(var y=0;y<imgdata.height;y++){  
                for(var x=0;x<imgdata.width;x++){  
                    var pv = Math.min(255,imgdata.data[(y*imgdata.width+x)*4]);  
                    pixCount[pv]++;  
                    }  
                }  
        ctx.clearRect(0,0,canvas.width,canvas.height);  
        var stImg = ctx.getImageData(0,0,canvas.width,canvas.height);  
        for(var x=0;x<256;x++){  
            var c = pixCount[x];  
            var h = stImg.height - Math.round(stImg.height*c/pixTotal);  
            for(var y=h;y<stImg.height;y++){  
                var i = (y*stImg.width+x)*4;  
              stImg.data[i]=stImg.data[i+1]=stImg.data[i+2]=0;  
              stImg.data[i+3]=255;  
            }  
        }  
        ctx.putImageData(stImg,0,0);
    }//这个是我子页的代码,传递的是数组r,可是调试的时候父页handle.rhistogram(r);显示有错误,这是什么原因呢.
      

  4.   

    句柄要申明为全局的,要不在你父页按钮里面引用不到
        var handle
        function rhistogram() {
            handle = window.open('rhistogram.html', 'newwindow1', 'height=500,width=256,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')
            handle.rhistogram(r);
        }
      

  5.   


    uncaught typeerror:object[object global]has no method 'rhistogram'
    还是这样啊
      

  6.   

    我需要点击一个按钮,然后打开新的窗口,在窗口中显示一个直方图。---------
    function rhistogram(r){这个方法你要放到rhistogram.html这个页面里面去啊你不就是通过父页给子页传递数据,这个方法放在父页干嘛。。你的图不是在打开的窗口中
      

  7.   

    本帖最后由 showbo 于 2014-01-03 14:32:20 编辑
      

  8.   

    我是放在子页面啊...
    没注意看你代码。。不用申明为全局变量也行,是新页面没加载完毕的问题。。放到onload事件中调用
        function rhistogram() {
            var handle = window.open('rhistogram.html', 'newwindow1', 'height=500,width=256,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')
            handle.onload = function () {//////
                handle.rhistogram(r);
            }
        }
    非常感谢...调试的时候直接跳过handle.rhistogram(r);了是怎么回事...
      

  9.   

    我是放在子页面啊...
    没注意看你代码。。不用申明为全局变量也行,是新页面没加载完毕的问题。。放到onload事件中调用
        function rhistogram() {
            var handle = window.open('rhistogram.html', 'newwindow1', 'height=500,width=256,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')
            handle.onload = function () {//////
                handle.rhistogram(r);
            }
        }
    非常感谢...调试的时候直接跳过handle.rhistogram(r);了是怎么回事...要在handle.rhistogram(r);打断点,不要再handle.onload这个位置,
      

  10.   

    我是放在子页面啊...
    没注意看你代码。。不用申明为全局变量也行,是新页面没加载完毕的问题。。放到onload事件中调用
        function rhistogram() {
            var handle = window.open('rhistogram.html', 'newwindow1', 'height=500,width=256,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')
            handle.onload = function () {//////
                handle.rhistogram(r);
            }
        }
    非常感谢...调试的时候直接跳过handle.rhistogram(r);了是怎么回事...要在handle.rhistogram(r);打断点,不要再handle.onload这个位置,
    在handle.rhistogram(r);打断点没反应啊。