H5 Switching Interface Returns Return Return Value

Mainly elaborates the knowledge of returning the value passed down, and encounters a lot of pits and confusion in doing the project, so here is a summary of the following points for you:

1.html files are essential to monitor click-and-switch events (interface A);

<li class="mui-table-view-cell" id="cheziinfo">
        <a class="mui-navigate-right"><img src="images/aichename/car.png"/ style="width:25px; float: left;margin-right:10px ;">Car Name <span id="aichename"></span></a>
    </li>

2. Click Event tap Event

document.getElementById("cheziinfo").addEventListener('tap', function() {
              mui.openwindws({
              url:"editorname.html",
              id:"editorname",
              extras: {
                    nama: "datebase",
                    imei:123456,
                } //Custom Extension Parameters
              })
            });

3. Receive B interface returns the value passed in

function getResult(r){
                document.getElementById("aichename").innerHTML = r; 
            }

At this point, the basic definition of page A is all about this, mainly focusing on parameters and functions getResult () that return values to receive; both follow simple, continue to look at interface B;

4. What Page B needs to do at this point is to receive the data passed from interface A, display it on the interface, and when returning to page A, get the value back to the interface A by evalJS

<input type="" name="" id="xiayibuss" value="" placeholder="Enter modified name" />
<input type="" name="" id="shebeiimei" value="" placeholder="input imei number" />
//Click the button
 <button id="xiayibu">Determine modifications</button>

The code to get the A interface is as follows:

var ws=null,wo=null,domready=false;
        function plusReady(){
            if(ws||!window.plus||!domready){
                return;
            }
            // Get Window Object
            ws=plus.webview.currentWebview();
            wo=ws.opener();
            var vText = ws.gpsname;
            var vTextimei = ws.imei;
            document.getElementById("xiayibuss").value = vText; 
            document.getElementById("shebeiimei").innerHTML = vTextimei;
        }
         if(window.plus){
            plusReady();
         }else{
            document.addEventListener("plusready",plusReady,false);
         }
         // Listen for DOMContentLoaded events
         document.addEventListener("DOMContentLoaded",function(){
            domready=true;
            plusReady();
         },false);

ok, now get the data of interface A, and then...
5. Return the value passed to the A interface by the current input

document.getElementById('xiayibu').addEventListener('tap',function(){
            var setname = document.getElementById("xiayibuss").value;
            var setimei = document.getElementById("xiayibuss").value;
            wo.evalJS("getResult('"+ setname  +"');");
            back();//Close Page B

          });

At this point, the two interfaces can transfer values to each other. A interface value - B interface - A interface, if you can help you, please pay attention to or collect, this is an original, rigorous reprint, thank you..goodbay!

Posted by chrislive on Sun, 26 Apr 2020 10:01:47 -0700