如何设置以下动态创建的HTML以重定向到mypage.aspx
?
Dim s As String = " <div style=""float: left; width: 716px; height: 25px; "">"
s += " <button type=""button"" id=""btnRedirect"" style=""float: right; width: 100px; font-size:12px;"" >Redirect</button>"
s += " </div>"
ScriptManager.RegisterStartupScript(Me.Page, Me.GetType(), "temp1", "<script type='text/javascript'> $('" + s + "').dialog({width: 750, height: 400,resizable: false});</script>", False)
答案 0 :(得分:1)
使用on
绑定到btnRedirect的点击事件。
使用的跨浏览器重定向功能取自here:
$('#btnRedirect').on('click',function(){
_Redirect('mypage.aspx');
});
function _Redirect (url) {
var ua = navigator.userAgent.toLowerCase(),
verOffset = ua.indexOf('msie') !== -1,
version = parseInt(ua.substr(4, 2), 10);
// IE8 and lower
if (verOffset && version < 9) {
var link = document.createElement('a');
link.href = url;
document.body.appendChild(link);
link.click();
}
// All other browsers
else { window.location.href = url; }
}