2009-11-28 5 views
0

나는 이와 같이 하이퍼 링크 (www.wow.com)가있는 변수가 있습니다. 이 값을여기 href 태그에 전달해야합니다. 내 실제 작업은 내 변수에서 새 탭으로 시간에 따라 변경되는이 하이퍼 링크를 여는 것입니다. 내가 asp.net 웹 응용 프로그램에서 C#으로 자바 스크립트를 사용했습니다.새 창에서 하이퍼 링크 C#

js에서 window.location 함수를 사용했지만 올바로 작동하지 않습니다. 누구든지 새로운 창이나 탭에서 하이퍼 링크를 여는 아이디어가 있습니까?

하이퍼 링크 값은 해당 변수에 따라 변경되어야하며 새 탭에서 열어야합니다. 누군가가 나를 아래이

을하는 데 도움이 될 수 있습니다 것은 Gmail을 내 이메일에서 나는이납니다 내 실제 코드

<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]);      
       %> 
<% 
      } 
%> 

에서 코드입니다. 내 웹 응용 프로그램을 통해 Gmail에 액세스했습니다. 그런 다음 내 메일 내용에 액세스했습니다. 그 메일 내용에서 하이퍼 링크를 가져 와서 별도의 탭에있는 모든 링크를 보여줘야합니다.

답변

1

새 창에서 링크를 열도록 강요하는 기본 HTML 방법은 target = "_ blank"값을 추가하는 것입니다.

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

지금까지 얻은 코드 샘플을 제공 할 수 있습니까? 도움을 쉽게합니다.

+0

좋은 답변 감사합니다. –