2

I wrote one hybrid application by using jQuery mobile. It is working on Android and iPhone, but on Windows Phone the UI is coming up, but the JavaScript functions are not working.

This is my code:

<html >
    <head>
           <script type="text/javascript">
            function  checkUser(){

                //here is my logic to to next screen
                         }
       </script>
   </head>
   <body>
     <div data-role="page" data-theme="b" id="page1">
          <p>
     <a data-role="button" data-transition="none" data-theme="e" onclick="checkUser(); "  rel="external"> Login </a>
          </p>
     </div>
   </body>
</html>

When I click the login button the checkUser function is not being called. What am I doing wrong?

4

4 回答 4

0

我使用 VS Express 2012 for Windows Phone 的 html 模板创建了一个新项目。

根据“nkchandra”的建议,我需要IsScriptEnabled在文件 MainPage.xaml 中启用 Javascript(请参阅 ):

<Grid x:Name="LayoutRoot" Background="Transparent">
    <phone:WebBrowser x:Name="Browser"
                      HorizontalAlignment="Stretch"
                      VerticalAlignment="Stretch"
                      Loaded="Browser_Loaded"
                      IsScriptEnabled = "True"
                      NavigationFailed="Browser_NavigationFailed" />
</Grid>
于 2012-11-05T08:54:55.120 回答
0

不幸的是,Windows Mobile 6 和可能的 Windows phone 浏览器不支持完整的 javascript 标准。例如,在 Windows Mobile 6.1.4(AKU 版本级别)之前,没有 onKey... javascript 支持。要查看是否存在 WinodwsMobile Internet Explorer Mobile (IEM) 不支持的内容,请启用 ShowScriptErrors:

// If you want Pocket IE to display script errors set this registry key:
// [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main] "ShowScriptErrors"=dword:00000001
// MSDN Knowledge Base Q306520
// Recommended !!

另请参阅http://forum.gpsgate.com/pop_printer_friendly.asp?TOPIC_ID=1499

我不知道,JQuery 在 WM 上的支持程度如何,但以下是调用 javascript 函数以进行按钮单击的工作代码片段:

<input type="button" style="width:90" name="pushbutton_0" value=" F2-Zrks" onfocus="javascript:doOnFocus(0);" onclick="javascript:doSubmit(0);">

~约瑟夫

于 2012-10-04T03:28:59.020 回答
0

You should have an href in there. For example: <a href="#" onclick="someFunction()">

于 2012-10-03T06:08:34.793 回答
0

你有一个很好的机会来使用不显眼的 JS——因为你使用了 jQuery,所以更是如此:

<html >
  <head>
    <script... jquery...></script>
       <script type="text/javascript">
          $(function() {
            $("#page1 a").on("click",function() {
              //here is my logic to to next screen
              return false; // or e.preventDefault()
            });
          });
   </script>
 </head>
 <body>
 <div data-role="page" data-theme="b" id="page1">
      <p>
 <a href="#" data-role="button" data-transition="none" data-theme="e" rel="external"> Login </a>
      </p>
 </div>
 </body>
 </html>
于 2012-10-03T06:19:12.637 回答