[英]C# open page in new tab
我有以下代碼:
string urlAccomodation = ar.GetAccommodationHashURL(
StudentId.ToString(),
sp.GetSysSetting("accomodationSecret"),
misc.GetAppSetting("urlAccommodation"));
string returnURL = "&url=" + Server.UrlEncode(
ar.GetHashURL(
StudentId.ToString(),
sp.GetSysSetting("accomodationSecret"),
"http://applicants.rac.ac.uk/default.aspx"));
string url = "window.open('" + urlAccomodation + returnURL + "_blank')";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Script", url, true);
我想做的是在新標簽頁中打開一個頁面。 對於Mozilla和Internet Explorer來說,它工作正常,但Chrome和Safari會在新窗口(而不是新標簽頁)中打開它。 你能幫忙嗎? (我為我的英語表示歉意)
不確定基於所提供的信息,可能仍然無濟於事,但您可能會錯誤地設置string url=
行的格式:
string url = "window.open('" + urlAccomodation + returnURL + "_blank')";
嘗試
string url = "window.open('" + urlAccomodation + returnURL + "','_blank')";
目標應該是window.open
方法的單獨參數,例如: window.open('some.aspx','_blank')
據我所知,這是瀏覽器設置,無法通過代碼進行控制。
我猜測由於適當的設置,它可以在FF和IE上運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.