0x80004005(NS_ERROR_FAILURE)[nsIDOMHTMLFormElement.submit] [英] 0x80004005 (NS_ERROR_FAILURE) [nsIDOMHTMLFormElement.submit]

查看:227
本文介绍了0x80004005(NS_ERROR_FAILURE)[nsIDOMHTMLFormElement.submit]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一种方法来检索一些数据(纬度,分数),并打开一个窗口来映射它们。

 函数openMapWindow(data){
alert(data);

var mapForm = document.createElement(form);
mapForm.target =地图;
mapForm.method =POST; //或post(如果适用)
mapForm.action =/map.php;

var mapInput = document.createElement(input);
mapInput.type =text;
mapInput.name =addrs;
mapInput.value = data;
mapForm.appendChild(mapInput);

document.body.appendChild(mapForm);

window.open(,Map,status = 0,title = 0,height = 600,width = 800);

mapForm.submit();

}

数据变量填充如下:





然而,我得到以下区域:

  mapInput.value = data; 




错误:未捕获的异常:
[异常... 组件返回
失败代码:0x80004005
(NS_ERROR_FAILURE)
[nsIDOMHTMLFormElement.submit]
nsresult:0x80004005
(NS_ERROR_FAILURE)位置:JS
frame :: http://www.xxx.xxx ::
openMapWindow :: line 244data:no]



行0



解决方案

它与浏览器的弹出窗口阻止程序有关。如果仔细观察错误,它将描述提交按钮作为问题,而不是mapValue.input行。



以下代码正在为我工​​作: / p>

http://jsfiddle.net/WDFNL/

  function openMapWindow(data){
alert(data);

var mapForm = document.createElement(form);
mapForm.target =地图;
mapForm.method =POST; //或post(如果适用)
mapForm.action =/map.php;

var mapInput = document.createElement(input);
mapInput.type =text;
mapInput.name =addrs;
mapInput.value = data;
mapForm.appendChild(mapInput);

document.body.appendChild(mapForm);

window.open(,Map,status = 0,title = 0,height = 600,width = 800);

mapForm.submit();
}
openMapWindow(' - 35.308401,149.124298-35.307841,149.124298');

我第一次收到您所描述的错误,但它与我的弹出窗口拦截器有关。一旦我授权jsfiddle.net被允许弹出窗口,它开始工作。



编辑



有一个简单的方法来测试,并提醒用户他们的弹出窗口阻止程序禁用地图:



http://jsfiddle.net/WDFNL/1/

  function openMapWindow(data){
var mapForm = document.createElement(form);
mapForm.target =地图;
mapForm.method =POST; //或post(如果适用)
mapForm.action =/map.php;

var mapInput = document.createElement(input);
mapInput.type =text;
mapInput.name =addrs;
mapInput.value = data;
mapForm.appendChild(mapInput);

document.body.appendChild(mapForm);

map = window.open(,Map,status = 0,title = 0,height = 600,width = 800);

if(map){
mapForm.submit();
} else {
alert('您必须允许此地图的弹出窗口正常工作。
}
}
openMapWindow(' - 35.308401,149.124298-35.307841,149.124298');

请注意 map 变量。您可以测试它,看看 window.open 是否返回一个窗口句柄,并根据结果相应地执行。


I have created a method to retrieve some data (lat,lon points) and open a window to map them.

function openMapWindow (data) {
    alert(data);

    var mapForm = document.createElement("form");
    mapForm.target = "Map";
    mapForm.method = "POST"; // or "post" if appropriate
    mapForm.action = "/map.php";

    var mapInput = document.createElement("input");
    mapInput.type = "text";
    mapInput.name = "addrs";
    mapInput.value = data;
    mapForm.appendChild(mapInput);

    document.body.appendChild(mapForm);

    window.open("", "Map", "status=0,title=0,height=600,width=800");

    mapForm.submit();

}

data variable is populated with the following:

Yet I get the following area on the line:

mapInput.value = data;

ERROR: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMHTMLFormElement.submit]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://www.xxx.xxx :: openMapWindow :: line 244" data: no]

Line 0

解决方案

It has to do with your browser's popup blocker. If you look closely at the error, it's describing the submit "button" as the problem, not the mapValue.input line.

The below code is working for me:

http://jsfiddle.net/WDFNL/

function openMapWindow (data) {
    alert(data);

    var mapForm = document.createElement("form");
    mapForm.target = "Map";
    mapForm.method = "POST"; // or "post" if appropriate
    mapForm.action = "/map.php";

    var mapInput = document.createElement("input");
    mapInput.type = "text";
    mapInput.name = "addrs";
    mapInput.value = data;
    mapForm.appendChild(mapInput);

    document.body.appendChild(mapForm);

    window.open("", "Map", "status=0,title=0,height=600,width=800");

    mapForm.submit();
}
openMapWindow('-35.308401,149.124298-35.307841,149.124298');

I did get the error you're describing at first, but it had to do with my popup blocker. Once I authorized jsfiddle.net to be allowed popups, it started working.

EDIT

There is an easy way to test for this and alert the user if their popup blocker is disabling the map:

http://jsfiddle.net/WDFNL/1/

function openMapWindow (data) {
    var mapForm = document.createElement("form");
    mapForm.target = "Map";
    mapForm.method = "POST"; // or "post" if appropriate
    mapForm.action = "/map.php";

    var mapInput = document.createElement("input");
    mapInput.type = "text";
    mapInput.name = "addrs";
    mapInput.value = data;
    mapForm.appendChild(mapInput);

    document.body.appendChild(mapForm);

    map = window.open("", "Map", "status=0,title=0,height=600,width=800");

    if (map) {
        mapForm.submit();
    } else {
        alert('You must allow popups for this map to work.');
    }
}
openMapWindow('-35.308401,149.124298-35.307841,149.124298');

Note the map variable. You can test it to see if window.open returned a window handle, and act accordingly depending on the result.

这篇关于0x80004005(NS_ERROR_FAILURE)[nsIDOMHTMLFormElement.submit]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆