【问题标题】:Accordion menu in windows phone 8 by using webbrowser control使用 webbrowser 控件在 windows phone 8 中的手风琴菜单
【发布时间】:2013-05-13 10:03:46
【问题描述】:

我正在使用以下 HTML 页面来制作手风琴控件:

<!DOCTYPE >
<html >
<head >
    <title></title>
        <script language="JavaScript" type="text/javascript" >
            function Show() {
                document.getElementById("tdfirst").style.display = 'block';

            }
            function Hide() {
                document.getElementById("tdfirst").style.display = 'none';
            }
            function Show2() {
                document.getElementById("tdsecond").style.display = 'block';
            }
            function Hide2() {
                document.getElementById("tdsecond").style.display = 'none';
            }
            function Show3() {
                document.getElementById("tdthird").style.display = 'block';
            }
            function Hide3() {
                document.getElementById("tdthird").style.display = 'none';
            }
 </script>
    <style type="text/css">
        .style1 {
            width: 164px;
        }
        .style2
        {
            height: 98px;

        }
        .style3
        {
            width: 110px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table>
    <tr style="border-style: solid; border-width: thin; border-color: inherit;">
    <div id="div1" >
    <td class="style1" 
            style="border: thin solid #000000; text-align: right;">
        <table><tr><td>Menu1</td><td class="style3">
            <img alt="" onclick="Show()" src="Image/down%20arrow.jpg" 
                style="height: 15px; margin-left: 0px"  /><img 
                alt="" onclick="Hide()"  src="Image/up%20arrow.jpg" style="height: 15px" /></td></tr></table> </td>
        </div>
    </tr>
    <tr>
    <div id="div2">
    <td id="tdfirst" class="style2"  
            style="border: thin solid #000080; text-align: left;display:none;"; >SubMenu1</td>
    </div>
    </tr>
    </table>
    <div>
    <table>
    <tr style="border-style: solid; border-width: thin; border-color: inherit;">
    <div id="div3" >
    <td class="style1" 
            style="border: thin solid #000000; text-align: right;">
        <table><tr><td>Menu2</td><td class="style3">
            <img  alt="" onclick="Show2()" src="Image/down%20arrow.jpg" 
                style="height: 15px; margin-left: 0px"  /><img 
                alt="" onclick="Hide2()"  src="Image/up%20arrow.jpg" style="height: 15px" /></td></tr></table> </td>
        </div>
    </tr>
    <tr>
    <div id="div4">
    <td id="tdsecond" class="style2"  
            style="border: thin solid #000080; text-align: left;display:none;"; >SubMenu2</td>
    </div>
    </tr>
    </table>
    <table>
    <tr style="border-style: solid; border-width: thin; border-color: inherit;">
    <div id="div5" >
    <td class="style1" 
            style="border: thin solid #000000; text-align: right;">
        <table><tr><td>Menu3</td><td class="style3">
            <img id="imgdown" alt="" onclick="Show3()" src="Image/down%20arrow.jpg" 
                style="height: 15px; margin-left: 0px"  /><img id="imgup"
                alt="" onclick="Hide3()"  src="Image/up%20arrow.jpg" style="height: 15px" /></td></tr></table> </td>
        </div>
    </tr>
    <tr>
    <div id="div6">
    <td id="tdthird" class="style2"  
            style="border: thin solid #000080; text-align: left;display:none;"; >SubMenu3</td>
    </div>
    </tr>
    </table>
    </div>
    </form>
</body>
    </html>

当我尝试在 WebBrowser 控件中显示此 HTML 时,什么都没有出现并且控件为空白。

XAML:

<phone:WebBrowser HorizontalAlignment="Left" Margin="0" VerticalAlignment="Top" x:Name="webBrowser1" Grid.Row="1" IsScriptEnabled="True" />

.cs:

  webBrowser1.Navigate(new Uri("/Html_Pages/AboutUs.html", UriKind.Relative));

谁能看到我做错了什么?我正在使用 VS2012 和 WP8 模拟器。

【问题讨论】:

    标签: c# javascript html windows-phone-8 webbrowser-control


    【解决方案1】:

    希望这会对您有所帮助。 NavigateToString()

    private void goNavigateToStringButton_Click(object sender, RoutedEventArgs e)
    {
        // Load HTML document as a string
        Uri uri = new Uri(@"pack://application:,,,/HTMLDocumentWithoutScript.html", UriKind.Absolute);
        Stream stream = Application.GetResourceStream(uri).Stream;
        using (StreamReader reader = new StreamReader(stream))
        {
          // Navigate to HTML document string
          this.webBrowser.NavigateToString(reader.ReadToEnd());
        }
    }
    

    来自:NavigateToString() method

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-03
      • 2011-05-01
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      • 2014-03-31
      • 2011-05-10
      • 1970-01-01
      相关资源
      最近更新 更多