按钮 onclick 应连同参数一起重定向到另一个 xhtml 页面
Button onclick should redirect to another xhtml page along with parameters
我有一个 table 从后端获取的值呈现为 json,
在其中一个单元格中,我有一个按钮,单击此按钮我想呈现另一个 xhtml 页面,但我还希望将参数与超链接一起传递如何实现,在此先感谢我正在发布我的代码以供参考,
$.get('../Paid_deep_dive', {type: "paid_performance", campaign_id: $campaign, s_date: start_date, e_date: end_date}, function (response) {
var data = response.paid_performance;
response_data = response;
$('table#tb2 TBODY').append('<tr><td width ="12%"><form><input type="button" class="btn btn-block btn-lg btn-inverse" onclick="loadtable2(' + elem.site_id + ')" value="' + elem.site_name + '" style="width:100%" ></form></td>' + elem.site_name + '</center></td><td align="center" width="33%"><center>' + elem.impressions.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td><td align="center" width="25%"><center>' + elem.ontarper + '%</center></td>;<td align="center"><center>' + elem.viewable_imp.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td></tr>');
});
在上面的代码中,我想在
处有一个超链接
onclick = "http://localhost:8080/Digiview_v2/faces/xhtml_files/paid_drill_down.xhtml?variable=" + parameter;
以及传递参数。有什么办法可以正确做到吗
您通过分配给 window.location.href
:
在 JS 中重定向
$('table#tb2 TBODY').append('<tr><td width ="12%"><form><input type="button" class="btn btn-block btn-lg btn-inverse" onclick="window.location.href=\'http://localhost:8080/Digiview_v2/faces/xhtml_files/paid_drill_down.xhtml?variable=' + encodeURIComponent(parameter) + '\'" value="' + elem.site_name + '" style="width:100%" ></form></td>' + elem.site_name + '</center></td><td align="center" width="33%"><center>' + elem.impressions.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td><td align="center" width="25%"><center>' + elem.ontarper + '%</center></td>;<td align="center"><center>' + elem.viewable_imp.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td></tr>');
我有一个 table 从后端获取的值呈现为 json,
在其中一个单元格中,我有一个按钮,单击此按钮我想呈现另一个 xhtml 页面,但我还希望将参数与超链接一起传递如何实现,在此先感谢我正在发布我的代码以供参考,
$.get('../Paid_deep_dive', {type: "paid_performance", campaign_id: $campaign, s_date: start_date, e_date: end_date}, function (response) {
var data = response.paid_performance;
response_data = response;
$('table#tb2 TBODY').append('<tr><td width ="12%"><form><input type="button" class="btn btn-block btn-lg btn-inverse" onclick="loadtable2(' + elem.site_id + ')" value="' + elem.site_name + '" style="width:100%" ></form></td>' + elem.site_name + '</center></td><td align="center" width="33%"><center>' + elem.impressions.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td><td align="center" width="25%"><center>' + elem.ontarper + '%</center></td>;<td align="center"><center>' + elem.viewable_imp.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td></tr>');
});
在上面的代码中,我想在
处有一个超链接onclick = "http://localhost:8080/Digiview_v2/faces/xhtml_files/paid_drill_down.xhtml?variable=" + parameter;
以及传递参数。有什么办法可以正确做到吗
您通过分配给 window.location.href
:
$('table#tb2 TBODY').append('<tr><td width ="12%"><form><input type="button" class="btn btn-block btn-lg btn-inverse" onclick="window.location.href=\'http://localhost:8080/Digiview_v2/faces/xhtml_files/paid_drill_down.xhtml?variable=' + encodeURIComponent(parameter) + '\'" value="' + elem.site_name + '" style="width:100%" ></form></td>' + elem.site_name + '</center></td><td align="center" width="33%"><center>' + elem.impressions.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td><td align="center" width="25%"><center>' + elem.ontarper + '%</center></td>;<td align="center"><center>' + elem.viewable_imp.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + '</center></td></tr>');