Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaScript不适用于Windows Mobile和Windows Phone_Javascript_Windows Phone 7_Jquery Mobile_Windows Mobile - Fatal编程技术网

JavaScript不适用于Windows Mobile和Windows Phone

JavaScript不适用于Windows Mobile和Windows Phone,javascript,windows-phone-7,jquery-mobile,windows-mobile,Javascript,Windows Phone 7,Jquery Mobile,Windows Mobile,我使用jQuery mobile编写了一个混合应用程序。它在Android和iPhone上运行,但在Windows Phone上,用户界面即将出现,但JavaScript功能不起作用 这是我的代码: <html > <head> <script type="text/javascript"> function checkUser(){ //here is my logic

我使用jQuery mobile编写了一个混合应用程序。它在Android和iPhone上运行,但在Windows Phone上,用户界面即将出现,但JavaScript功能不起作用

这是我的代码:

<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>

函数checkUser(){
//这是我下一屏的逻辑
}

登录


当我单击登录按钮时,
checkUser
功能未被调用。我做错了什么?

你应该有一个
href
。例如:

您应该在那里有一个
href
。例如:

您有一个很好的机会使用不引人注目的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>

$(函数(){
$(“#第1页a”)。在(“单击”,函数(){
//这是我下一屏的逻辑
返回false;//或e.preventDefault()
});
});


您有一个很好的机会使用不引人注目的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>

$(函数(){
$(“#第1页a”)。在(“单击”,函数(){
//这是我下一屏的逻辑
返回false;//或e.preventDefault()
});
});


不幸的是,Windows Mobile 6和可能的Windows phone浏览器不支持完整的javascript标准。例如,在Windows Mobile 6.1.4(AKU版本Levelel)之前,没有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 !!
另见

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

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


~josef

不幸的是,Windows Mobile 6和可能的Windows phone浏览器不支持完整的javascript标准。例如,在Windows Mobile 6.1.4(AKU版本Levelel)之前,没有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 !!
另见

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

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


~josef

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

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

<Grid x:Name="LayoutRoot" Background="Transparent">
    <phone:WebBrowser x:Name="Browser"
                      HorizontalAlignment="Stretch"
                      VerticalAlignment="Stretch"
                      Loaded="Browser_Loaded"
                      IsScriptEnabled = "True"
                      NavigationFailed="Browser_NavigationFailed" />
</Grid>

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

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

<Grid x:Name="LayoutRoot" Background="Transparent">
    <phone:WebBrowser x:Name="Browser"
                      HorizontalAlignment="Stretch"
                      VerticalAlignment="Stretch"
                      Loaded="Browser_Loaded"
                      IsScriptEnabled = "True"
                      NavigationFailed="Browser_NavigationFailed" />
</Grid>


Correct@adam这可能是问题的原因。或者更好:return someFunction(),其中someFunction返回false我更新如下。但是仍然没有调用Correct@adam这可能是问题的原因。或者更好:return someFunction(),其中someFunction返回false我更新如下。但是仍然没有调用我正在尝试使用的方法如下。$(function(){$(“#page1 a”)。在(“单击”,function(){//这是我下一个屏幕警报的逻辑(“请提供用户名”);navigator.notification.alert(“Hi”);return false;//或e.preventDefault()});

但函数仍然没有调用。我尝试使用如下方法。$(function(){$(“#page1 a”)。在(“单击”,function(){//这是我下一个屏幕警报的逻辑(“请提供用户名”);navigator.notification.alert(“Hi”);return false;//或e.preventDefault()});

但函数仍然没有调用。我假设您使用的是WebBrowser控件。如果是这样,您可以使用InvokeScript方法来执行JavaScript。参考:Windows Phone 7中的JavaScript函数如果您正在使用
WebBrowser
组件并将html传递给该组件,请确保启用该脚本<代码>我已经这样做了。但它不起作用。我假设您使用的是WebBrowser控件。如果是这样,您可以使用InvokeScript方法来执行JavaScript。参考:Windows Phone 7中的JavaScript函数如果您正在使用
WebBrowser
组件并将html传递给该组件,请确保启用该脚本<代码>我已经这样做了。但它不起作用。