This is due to the browser popup blocker. If you look closely at the error, it describes submit "button" as a problem, not the mapValue.input line.
The following code works 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');
At first I got the error you are describing, but this is due to my popup blocker. As soon as I allowed jsfiddle.net to allow pop-ups, it started working.
EDIT
There is an easy way to check this and alert the user if his pop-up blocker disables the card:
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');
Pay attention to the map variable. You can check it to see if window.open returned a window handle and acts accordingly depending on the result.
Jared farrish
source share