0
我做了以下jQuery脚本。我试图在新选项卡中打开此网址,但在Internet Explorer中无法使用。如何将值传递给按钮,以便我可以在新选项卡中打开?如何将值传递给href属性和目标?
var checkSurl = "<%=checkSURL%>";
var iframeDetalleSOnLoad = function(obj) {
$(obj).show();
};
$(document).ready(function() {
$("#detalleS").html("");
$("[name=buscar]").on("click", function() {
var bottonBuscar = $(this);
var numS = $("#numS");
if (numS.val() == "") {
alert("El numero de s no puede estar vacestar vacío");
}
else {
// Call per verifica existence of s
$.ajax({
url: checkSurl + "?numS=" + $("#numS").val(),
success: function(response) {
var isS = eval(response.trim());
console.log(isS);
// returns che il s esiste
if (isS) {
var targetURL = "https://www.sample.es/cgi-bin/fccgi.exe?w3exec=DET&CONTROL=samole&ID=" + numS.val();
bottonBuscar.parent('a').attr('href',targetURL);
bottonBuscar.parent('a').attr('target', '_blank');
console.log(bottonBuscar.parent('a').attr('href',targetURL));
console.log(bottonBuscar.parent('a').attr('target', '_blank'));
}
else {
alert("EL NUMERO DE S QUE HA INSERTADO NO ES CORRECTO.");
return false;
}
},
error: function(error) {
$("#detalleS").html(error);
}
});
}
,我想改变HTML元素的href和可能的目标设定为 '_blank'。
<div class="formulario" >
<div align="center">
<a href="#"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('buscar','','<%=request.getContextPath()%>/img/buttonBuscarEnvio_over.png',1)">
<img src="<%=request.getContextPath()%>/img/buttonBuscarEnvio.png" alt="Buscar S"
name="buscar" border="0" id="buscar"></a>
</div>
谢谢。已经解决了,而不是window.open(targetURL,“_blank”);我写道:oNewWindow = window.open(targetURL); console.log()不是问题 – llesh