Con el método window.open abro un nuevo sitio con parámetros, que tengo que pasar por método de publicación. Encontré una solución, pero desafortunadamente no funciona. Este es mi codigo:
<script type="text/javascript">
function openWindowWithPost(url,name,keys,values)
{
var newWindow = window.open(url, name);
if (!newWindow) return false;
var html = "";
html += "<html><head></head><body><form id='formid' method='post' action='" + url +"'>";
if (keys && values && (keys.length == values.length))
for (var i=0; i < keys.length; i++)
html += "<input type='hidden' name='" + keys[i] + "' value='" + values[i] + "'/>";
html += "</form><script type='text/javascript'>document.getElementById(\"formid\").submit()</sc"+"ript></body></html>";
newWindow.document.write(html);
return newWindow;
}
</script>
A continuación, creo matrices:
<script type="text/javascript">
var values= new Array("value1", "value2", "value3")
var keys= new Array("a","b","c")
</script>
Y llamar a la función por:
<input id="Button1" type="button" value="Pass values" onclick="openWindowWithPost('test.asp','',keys,values)" />
Pero, cuando hago clic en este botón, el sitio test.asp está vacío (por supuesto, intento obtener valores de paso - Request.Form("b")
).
¿Cómo podría resolver este problema, por qué no puedo obtener valores de paso?
fuente