【问题标题】:Remove (#) from URL in Silverlight从 Silverlight 中的 URL 中删除 (#)
【发布时间】:2015-04-21 07:53:59
【问题描述】:

我有一个网址,例如http://localhost:8000/#Test/Method

我正在做以下事情:

System.Windows.Browser.HtmlPage.Window.CurrentBookmark = string.Empty;

只删除测试/方法而不是'#'

我需要修改浏览器网址 作为: http://localhost:8000/

关于如何解决这个问题的任何想法?

【问题讨论】:

    标签: javascript c# html silverlight


    【解决方案1】:

    如果您正在操作String,您可以使用以下方法:

    String Url = "Foo#Bar";
    Url = Url.Replace("#", string.Empty);
    

    【讨论】:

      【解决方案2】:

      使用正则表达式

      String url = "http://localhost:8000/#Test/Method"
          url = url.replace(/#/g, "");
      

      上面的reg表达式将扫描所有出现的'#'字符并替换为空字符

      【讨论】:

      • 你到底想要什么?
      • 'localhost:8000/#test/method' 在加载请求的页面后,我需要将其更新为 'localhost:8000'。问题是如果请求相同的 URL,则它不会打开,因为以前的 URL 和当前的 URL 相同。出于这个原因,我需要删除带有 # 符号的哈希书签
      • System.Windows.Browser.HtmlPage.Window.CurrentBookmark = string.Empty;将删除测试/方法 na??然后 System.Windows.Browser.HtmlPage.Window.CurrentBookmark = System.Windows.Browser.HtmlPage.Window.CurrentBookmark.replace(/#/g, "");将删除#
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-02
      • 2018-09-18
      • 2014-04-24
      • 2015-06-15
      • 2012-07-04
      • 2014-06-12
      相关资源
      最近更新 更多