【问题标题】:Link two html pages ( java script)链接两个 html 页面(javascript)
【发布时间】:2018-12-02 17:29:47
【问题描述】:

我有两页。一个是 index.html,另一个是 pk_canonical.html。我想将 pk-canonical.html 页面与索引页面链接,作为下拉列表中的选项之一。当我尝试运行页面时。两个页面都单独运行良好,但是当我从索引页面的下拉列表中选择选项时,它说“服务器没有找到与请求的 URI 匹配的任何内容”。它不会进入 pk_canonical 页面。请帮助我我哪里出错了。下面是代码。

index.html:

<div class="content">
    <!--<p>-->
        <!--<select data-bind="options: Algorithms,-->
                       <!--optionsText: 'algoName',-->
                       <!--value: selectedAlgorithm,-->
                       <!--optionsCaption: 'Choose...'"></select>-->
    <!--</p>-->

    <!--<div data-bind="visible: selectedAlgorithm"> &lt;!&ndash; Appears when you select something &ndash;&gt;-->
        <!--You have chosen a country with population-->
        <!--<span data-bind="text: selectedAlgorithm ? selectedAlgorithm.algoPage : 'unknown'"></span>.-->
    <!--</div>-->
    <select id="algoSelect" onchange="algoSel(this)">
        <option selected="selected" disabled="disabled">Select an algorithm</option>
        <option value="Nussinov.html">Nussinov - max. #bp structure</option>
        <option value="counting.html">Structure Counting</option>
        <option value="McCaskill.html">McCaskill - structure probabilities</option>
        <option value="MEA.html">MEA structure</option>
        <option value="co-folding.html">Co-folding interactions</option>
        <option value="hybrid-only.html">hybrid-only interactions</option>
        <option value="accessibility.html">accessibility-based interactions</option>
        <option value="pk_canonical.html">canonical pseudoknot</option>


    </select>

    <div id="algopage">

    </div>

    <script type="application/javascript">
        function loadPage(){
            console.log("algo selected:", document.location);
            var $_GET = {};

            document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
                function decode(s) {
                    return decodeURIComponent(s.split("+").join(" "));
                }

                $_GET[decode(arguments[1])] = decode(arguments[2]);
            });

//            console.log($_GET['id']);
            $(algopage).load($_GET['id']);
//            console.log("algo loaded");

        };

        function algoSel(algo){
            window.location='index.html?id=' + algo.value;

        };

    </script>

</div>


</body>

pk_canonical.html:

 <div class="row" id="introduction">
   <div class="colW600">
     The algorithm by
     <a href="https://doi.org/10.1093/nar/gkm258">Reeder&Giegerich</a>
     briefly sketch the way to implement  an extension of the usual dynamic programming (DP) scheme for RNA folding [5,6].
     <br />
     Helical stem called 'Canonical stem' which comprises only canonical Watson-Crick base pairs and usually ends with two canonical C=G base pairs before the internal loop.
     C(i,j) =  Maximal length of canonical stem with outermost base pairs (i,j)

     <br />
     A canonical pseudoknot consists of two crossing canonical stems.
     <br />
     The (suboptimal) backtrace procedure the pseudoknot matrix is handled at the end.
     <br />
     <br />
     Here, Since only two helices participate in one pseudoknot, we loop over all possible knots in one O(n4) loop and store the result in a two-dimensional matrix. 
     Finally, the traceback is visualized. 
   </div>
   <div class="colW150">
    <img alt="Canonical pseudoknot" src="output-onlinejpgtools.png" width=120 height=90 >
  </div>
 </div>

【问题讨论】:

    标签: javascript html uri


    【解决方案1】:

    用这个替换你的函数,

     function algoSel(algo){
         window.location= algo.value;
     };
    

    您好,所以小问题来自您的 algoSel(algo) 函数,只需将值 algo.value 分配给 window.location 以使其重定向到您的 pk_canonical 算法页面。谢谢。

    这里,

        function algoSel(algo){
            window.location='index.html?id=' + algo.value;
        }
    

    ,您告诉 js 重定向到您的 index.html 页面并查找名为 pk_canonical.html 的资源/路径,而不是告诉它只重定向到 pk_canonical.html

    【讨论】:

    • 嗨,感谢您的解决方案。但它仍然无法正常工作。它说 pk_canonical.html' 不允许加载。访问被拒绝。
    • 嗨..对不起..浏览器不支持。现在它工作正常。谢谢
    • 实际上,Microsoft edge 不支持 pk_canonical 页面,但它支持所有其他 html 页面。在 Opera 和 chrome 中,它支持 pk_canonical 页面,但不支持所有其他页面。
    • 因为,edge 支持所有其他算法,你能告诉我为什么单独 pk_canonical 不支持
    • 如何让文件在我自己的本地主机上进行测试
    猜你喜欢
    • 1970-01-01
    • 2020-10-03
    • 2016-01-05
    • 1970-01-01
    • 1970-01-01
    • 2021-12-11
    • 1970-01-01
    • 1970-01-01
    • 2015-10-10
    相关资源
    最近更新 更多