Asp.net 如何从code中打开类似www.gmail.com的链接?

Asp.net 如何从code中打开类似www.gmail.com的链接?,asp.net,Asp.net,我想打开一个URL,就像用户单击按钮一样。如何在“代码”的“新建”选项卡中打开此链接(我想从数据库中读取链接)?只需单击按钮执行下面的一行即可 window.location="http://www.google.com"; 只需在单击按钮时执行下面的行 window.location="http://www.google.com"; 函数openlink() { document.location.href=”http://www.gmail.com"; } 函数openlink()

我想打开一个URL,就像用户单击按钮一样。如何在“代码”的“新建”选项卡中打开此链接(我想从数据库中读取链接)?

只需单击按钮执行下面的一行即可

window.location="http://www.google.com";

只需在单击按钮时执行下面的行

window.location="http://www.google.com";

函数openlink()
{
document.location.href=”http://www.gmail.com";
}

函数openlink()
{
document.location.href=”http://www.gmail.com";
}

像这样从代码后面的页面调用JavaScript

Page.ClientScript.RegisterStartupScript(this.GetType(), 
"onLoad", "openNewWindow()", true);


<script language="JavaScript">
 <!-- hide
 function openNewWindow() {
 popupWin = window.open('http://webdesign.about.com/',
 'open_window',
 'menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=640, height=480, left=0, top=0')
 }
 // done hiding -->
 </script>

Page.ClientScript.RegisterStartupScript(this.GetType(),
“onLoad”、“openNewWindow()”,true);

您也可以使用window.location(“http://www.yourpath.com”

像这样从页面后面调用JavaScript代码

Page.ClientScript.RegisterStartupScript(this.GetType(), 
"onLoad", "openNewWindow()", true);


<script language="JavaScript">
 <!-- hide
 function openNewWindow() {
 popupWin = window.open('http://webdesign.about.com/',
 'open_window',
 'menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=640, height=480, left=0, top=0')
 }
 // done hiding -->
 </script>

Page.ClientScript.RegisterStartupScript(this.GetType(),
“onLoad”、“openNewWindow()”,true);
您也可以使用window.location(“http://www.yourpath.com)

您可以使用:

Response.Redirect
方法导航到另一个网页。

您可以使用:

Response.Redirect

方法导航到另一个网页。

如我使用之前建议的那样

Response.Redirect("http://www.gmail.com")

这应该是可行的,因为该方法也是为绝对URL设计的。在我使用之前,请不要保留http://前缀。

Response.Redirect("http://www.gmail.com")

这应该是可行的,因为该方法也是为绝对URL设计的。不要保留http://前缀。

我想从数据库中读取链接并在“新建”选项卡中打开它。如何使用此代码?传递变量值,如函数openNewWindow(dynamicPath)Page.ClientScript.RegisterStartupScript(this.GetType(),“onLoad”,“openNewWindow(“+YourDynamicPathFromDB.Tostring()+”),true);Page.ClientScript.RegisterStartupScript(this.GetType(),“onLoad”,“openNewWindow(')”,true);函数openNewWindow(Path){}谢谢,它可以在弹出窗口中打开,但可以在新选项卡中打开吗?这取决于用户的设置。我想从数据库中读取链接并在新选项卡中打开它。如何使用此代码?传递变量值,如函数openNewWindow(dynamicPath)Page.ClientScript.RegisterStartupScript(this.GetType(),“onLoad”,“openNewWindow(“+YourDynamicPathFromDB.Tostring()+”),true);Page.ClientScript.RegisterStartupScript(this.GetType(),“onLoad”,“openNewWindow(')”,true);函数openNewWindow(Path){}谢谢,它可以在弹出窗口中打开。可以在新选项卡中打开吗?这取决于用户的设置。谢谢,它可以工作,但是如果我想在新选项卡中打开,我应该怎么做?@iCoder删除您的第一条评论,然后谢谢,它可以工作,但如果我想在新选项卡中打开,我该怎么办?@iCoder删除您的第一条评论,然后