简体   繁体   English

在新窗口中的超链接C#

[英]hyperlink in new window c#

I have a variable with hyper links (www.wow.com) like this. 我有一个这样的超链接(www.wow.com)变量。 I have to pass this value to <a href=""> here in this href tag. 我必须将此值传递给此href标记中的<a href=""> My real task is to open this hyper links which will change time by time in my variable, in new tabs. 我真正的任务是打开此超级链接,该链接将在新标签中的变量中随时间变化。 For that I have used javascript in my asp.net web application with c#. 为此,我在C#中的asp.net Web应用程序中使用了javascript。

I have used window.location function in js, but its not working correctly. 我在js中使用了window.location函数,但无法正常工作。 Does any one have an idea to open that hyper links in new window or tabs. 是否有人有想法在新窗口或标签中打开该超级链接。

The hyper link value should change as per that variable and should open in new tabs. 超链接值应根据该变量进行更改,并应在新选项卡中打开。 Can anyone help me to do this 谁能帮我做到这一点

below is a code snippet from my actual code 以下是我实际代码中的代码片段

<td class="emails-table-cell" colspan="2">
        <asp:Literal ID="BodyLiteral" runat="server" />
        <%
            // *** Write to file ***

            // Specify file, instructions, and privelegdes
            FileStream file = new FileStream("test.html", FileMode.OpenOrCreate, FileAccess.Write);

            // Create a new stream to write to the file
            StreamWriter sw = new StreamWriter(file);

            // Write a string to the file
            sw.Write(BodyLiteral.Text);

            // Close StreamWriter
            sw.Close();

            // Close file
            file.Close();

            var text = File.ReadAllText(@"d:\test.html");

            Regex regex = new Regex("href\\s*=\\s*\"([^\"]*)\"", RegexOptions.IgnoreCase);
            MatchCollection matches = regex.Matches(text);
            //Response.Write(matches);
            foreach (Match match in matches)
            {
                Response.Write(match.Groups[1]);                    
                %>
<%
            }
%>

I'm getting this from my email that is gmail. 我是从我的Gmail电子邮件中收到此邮件的。 I have accessed my gmail through my web application. 我已经通过Web应用程序访问了我的gmail。 Then I have accessed my mail contents. 然后,我已经访问了邮件内容。 From that mail contents I have to fetch hyperlinks and show all the links in separate tabs that is the output i'm looking for. 从邮件内容中,我必须获取超链接,并在单独的选项卡中显示所有链接,这是我想要的输出。

The basic HTML method of forcing a link to open in a new window is to add a target="_blank" value. 强制链接在新窗口中打开的基本HTML方法是添加target =“ _ blank”值。

<a href="http://www.wow.com/" target="_blank">Go to WOW</a>

Can you provide a code sample of what you've got so far? 您能否提供到目前为止的代码示例? It will make it easier to assist. 这将使协助变得更容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM