首页 \ 问答 \ 在Javascript for IE11中将Child的文件输入对象传递给Parent窗口(Passing File Input Object of Child to Parent window in Javascript for IE11)

在Javascript for IE11中将Child的文件输入对象传递给Parent窗口(Passing File Input Object of Child to Parent window in Javascript for IE11)

有没有办法可以将子窗口中的文件输入的DOM对象传递给父窗口? 我尝试appendChild它在Firefox中运行良好,但在IE中没有,当我使用时,innerHTML不会将文件的值复制到父级,但它只是在父级中创建空的HTML文件输入元素。

追加孩子(在IE中工作正常,但不适用于Firefox)

var element = window.opener.document.getElementById("files_div");
element.parentNode.appendChild(document.getElementById("file0"));

InnerHTML(在任何地方都可以正常工作,但不会将整个对象复制到父对象)

window.opener.document.getElementById("files_div").innerHTML = document.getElementById("files_div").innerHTML;

出于安全原因,我不能这样做:

window.opener.document.getElementById("file0").value = document.getElementById("file0").value

Is there any way that I can pass a DOM object of a file input from the child window to parent? I tried to appendChild it works fine in Firefox but not in IE and when I use, innerHTML its not copying the value of the file to the parent but it was just creating the empty HTML file input element within the parent.

Appending Child (Works fine in IE but not Firefox)

var element = window.opener.document.getElementById("files_div");
element.parentNode.appendChild(document.getElementById("file0"));

InnerHTML(works fine everywhere but does not copy the entire object to parent)

window.opener.document.getElementById("files_div").innerHTML = document.getElementById("files_div").innerHTML;

I can't do this because of security reasons:

window.opener.document.getElementById("file0").value = document.getElementById("file0").value

原文:https://stackoverflow.com/questions/26352435
更新时间:2022-07-05 09:07

最满意答案

终于弄清楚这个了解更多...它现在有意义,但之前没有。 这是新的'display'函数,将由OP中的一个替换。 当然,还需要进行一些其他更改...例如,在新信息窗口中显示所有聚类标记数据,但这是让窗口工作的要点。

//集群函数做东西函数multiChoice(clickedCluster){//集群标记
var markers = clickedCluster.getMarkers();

if (markers.length > 1)
{
    //create the info window
    var infoWindow = new google.maps.InfoWindow({
        content: ''+
            '<p>'+markers.length+' = length</p>'+
            '<p>testing blah blah</p>',
        position: clickedCluster.center_
    });

    //display the infowindow
    infoWindow.open(clickedCluster.map_);

    return false;
}
return true;

};


Finally figured this out playing around with it some more... it makes sense now, but didn't before. Here is the new 'display' function to be replaced by the one in the OP. Of course, there are a few other change needed yet... showing all clustered marker data in the new info window for example, but this is the gist of getting the window to work.

//cluster function to do stuff function multiChoice(clickedCluster) { //clusters markers
var markers = clickedCluster.getMarkers();

if (markers.length > 1)
{
    //create the info window
    var infoWindow = new google.maps.InfoWindow({
        content: ''+
            '<p>'+markers.length+' = length</p>'+
            '<p>testing blah blah</p>',
        position: clickedCluster.center_
    });

    //display the infowindow
    infoWindow.open(clickedCluster.map_);

    return false;
}
return true;

};

相关问答

更多
  • 在地图元素或指令元素上添加ng-cloak属性。 “ngCloak指令用于防止浏览器短暂显示Angular html模板” http://docs.angularjs.org/api/ng.directive:ngCloak Add the ng-cloak property on your map element or on your directive element. "The ngCloak directive is used to prevent the Angular html template ...
  • 终于弄清楚这个了解更多...它现在有意义,但之前没有。 这是新的'display'函数,将由OP中的一个替换。 当然,还需要进行一些其他更改...例如,在新信息窗口中显示所有聚类标记数据,但这是让窗口工作的要点。 //集群函数做东西函数multiChoice(clickedCluster){//集群标记 var markers = clickedCluster.getMarkers(); if (markers.length > 1) { //create the info window v ...
  • 很抱歉浪费你的时间。 显然这是一个已知的,未修复的gmap.js错误: https://github.com/hpneo/gmaps/issues/373 解决方法是在gmaps.js中找到此代码: if (options.callback) { options.callback(self.routes, result, status); } 并替换为: if (options.callback) { options.callback(result.routes, re ...
  • 可以通过GMaps.el.clientWidth和GMaps.el.clientHeight独立访问宽度和高度。 width and height can be accessed independently through GMaps.el.clientWidth and GMaps.el.clientHeight.
  • 解决我的问题是使用map.removePolygon方法: var paths = []; var oldPolygon; function drawPoly(p1, p2) { paths.push([p1, p2]); console.log(paths); polygons = map.drawPolygon({ paths: paths, strokeColor: '#432070', strokeOpacity: 1, ...
  • 我是否正确地说我应该能够使用该ID = 1234来定位它? 我不这么认为。 文档非常不完整,在gmaps.js里面我找不到任何具有通过属性访问标记的功能。 但是你可以扩展原型: GMaps.prototype.markerById=function(id){ for(var m=0;m
  • 我有谷歌地图的简单示例, 希望它有所帮助 在关闭BODY标签之前,插入此标签