2017-10-29 20 views
0

私は現在、Xamarinのメンバーが提供していたソリューションで働いていますthis link 私は基本的に4桁の暗証番号を入力して送信ボタンに転送する必要があります。コードビハインドで書かれたログインページ。ここ はJSと私のHTMLです:hybridWebViewページXamarin.FormsのJavascriptから別のContentPageを開く

<html> 
<head> 
<style> 
    .phone-field { 
     margin: 50px; 
     font-size: 20px; 
    } 
    .phone-input { 
     width: 13px; 
     text-align: center; 
     font-size: 16px !important; 
     height: 1.75em; 
     border: 0; 
     outline: 0; 
     background: transparent; 
     border-bottom: 2px solid #ddd; 
     margin-right: 2px; 
     margin-left: 2px; 
    } 

    [placeholder]:focus::-webkit-input-placeholder { 
     transition: opacity 0.5s 0.0s ease; 
     opacity: 0; 
    } 
</style> 
</head> 
<body> 
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> 

<div class="phone-field"> 
    <form> 
     <input class="phone-input" id="one" name="phone-input" size="1" maxlength="1" placeholder=""> 
     <input class="phone-input" id="two" name="phone-input" size="1" maxlength="1" placeholder=""> 
     <input class="phone-input" id="three" name="phone-input" size="1" maxlength="1" placeholder=""> 
     <input class="phone-input" id="four" name="phone-input" size="1" maxlength="1" placeholder=""> 
     <input type="submit" onclick="javascript:invokeCSCode($('#one').val()+$('#two').val()+$('#three').val()+$('#four').val());" value="submit"> 
    </form> 
</div> 

<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script> 
<script type="text/javascript"> 
    $(document).ready(function() { 

     $('body').on('keyup', 'input.phone-input', function() { 
      var key = event.keyCode || event.charCode; 
      var inputs = $('input.phone-input'); 
      if (($(this).val().length === this.size) && key != 32) { 
       inputs.eq(inputs.index(this) + 1).focus(); 
      } 
      if (key == 8 || key == 46) { 
       var indexNum = inputs.index(this); 
       if (indexNum != 0) { 
        inputs.eq(inputs.index(this)).val('').focus(); 
        inputs.eq(inputs.index(this) - 1).focus(); 
       } 
      } 

     }); 
    }); 

</script> 
    <script type="text/javascript"> 
     $('.inputs').keyup(function() { 
      if (this.value.length == this.maxLength) { 
       $(this).next('.inputs').focus(); 
      } 
     }); 
     function log(str) { 
      $('#result').text($('#result').text() + " " + str); 
     } 

     function invokeCSCode(data) { 
      try { 
       log("Sending Data:" + data); 
       invokeCSharpAction(data); 
      } 
      catch (err) { 
       log(err); 
      } 
     } 
    </script> 
</body> 

私は(JSBridge throgh)C#と呼ばれ​​ている行を参照してください。

hybridWebView.RegisterAction (data => DisplayAlert ("Alert", "Hello " + data, "OK")); 

を、私は置く代わりに、この行の試してみました:

hybridWebView.RegisterAction(data => new PageNext()); 

しかし、動作しません。

基本的に、私はjavascriptから新しいページを呼び出す必要があります。

hybridWebView.RegisterAction(data => Navigation.PushAsync (new PageNext())); 

またはあなたのページがモーダルのように表示されなければならない場合は、代わりのRegisterActionでNavigation.PushModalAsync (new PageNext());を使用して試みることができる:

答えて

0

はそうのように、ナビゲーションスタック上に新しいPageNextページを押してみてください。

+0

今、アプリケーションから終了しました。何らかの理由で私はこのxamarinソリューションでコードをデバッグすることができません(おそらくJSを含んでいるからです) – Stefan0309

+0

何の例外がありますか?なぜあなたはコードをデバッグできませんか? 「アプリケーションから終了する」よりも詳細を投稿した場合、私は助けることができるかもしれません:) –

関連する問題