How does the front-end js call OC to pass parameters?

I am the front-end js,. I need to pass 4 parameters to Android and ios through OC, they do the sharing function, and then return to me whether the sharing is successful.
how should it be implemented? there had better be no compatibility problems, now both Android and ios versions are so new. The method I"m using now doesn"t seem to be safe enough.

<html>
<header>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script type="text/javascript">
        function showAlert(message) {
            alert(message);
        }

        function loadURL(url) {
            var iFrame;
            iFrame = document.createElement("iframe");
            iFrame.setAttribute("src", url);
            iFrame.setAttribute("style", "display:none;");
            iFrame.setAttribute("height", "0px");
            iFrame.setAttribute("width", "0px");
            iFrame.setAttribute("frameborder", "0");
            document.body.appendChild(iFrame);
            iFrame.parentNode.removeChild(iFrame);
            iFrame = null;
        }
        function firstClick() {
            loadURL("firstClick://shareClick?title=&content=&url=&imageUrl=");
        }

    </script>
</header>

<body>
    <button type="button" onclick="firstClick()">Click Me!</button>
</body>

</html>

can be used: dsbridge , easy to use, compatible with Apple Android


there is no need for iFrame to directly use location.href to jump to the protocol you negotiated.

app side they will intercept you have to jump, to carry out the corresponding.

your protocol also lacks a callback function that tells them which function to call and what arguments to pass.

judge the terminal to distinguish between wap and webview

example:

function callback(result) {
     console.log(result);//  html alert app
 }
       location.href =  "firstClick://shareClick?title=&content=&url=&imageUrl=&cb=callback";
         
       appcallback 
       
        app callback (  )
        
       
Menu