试图动态地将一个html页面嵌入到另一个html页面中(Trying to dynamically embed one html page inside of another)

编程入门 行业动态 更新时间:2024-10-12 03:16:34
试图动态地将一个html页面嵌入到另一个html页面中(Trying to dynamically embed one html page inside of another) <H2> Would you like to bounce an instance or application?</H2> <form name="dropDown" method="POST"> <select name="choiceDropDown" onchange="include()"> <option value="1">Instance Level</option> <option value="2">Application Level</option> </select> </form> <div id="inst" class="outsidePages"><jsp:include page='Instance_List.htm'/></div> <!-- END CONTAINER --> </td> </tr> </table> <!-- end content --> </td> </tr> </table> </div> </div> <div id="footerWrapper"> <div id="footer">Footer content goes here</div> </div> </body> <script type="text/javascript"> function include() { var container = document.getElementById("inst"); container.innerHTML = ""; container.innerHTML = " <jsp:include page='Home.htm'/> "; } </script> </html>

所以对于上面的脚本,我想要做的是如果下拉框改变,那么div“inst”应该改变,以便它包括不同的页面。 问题是当我试图做到这一点时,它打破了。 如果我使container.innerHTML = "Good morning"或其他任何工作正常。 任何想法为什么发生这种情况

<H2> Would you like to bounce an instance or application?</H2> <form name="dropDown" method="POST"> <select name="choiceDropDown" onchange="include()"> <option value="1">Instance Level</option> <option value="2">Application Level</option> </select> </form> <div id="inst" class="outsidePages"><jsp:include page='Instance_List.htm'/></div> <!-- END CONTAINER --> </td> </tr> </table> <!-- end content --> </td> </tr> </table> </div> </div> <div id="footerWrapper"> <div id="footer">Footer content goes here</div> </div> </body> <script type="text/javascript"> function include() { var container = document.getElementById("inst"); container.innerHTML = ""; container.innerHTML = " <jsp:include page='Home.htm'/> "; } </script> </html>

So for the script above what I want to do is if the drop box changes then the div "inst" should change so that it is including a different page. The problem is when I try to do this it breaks. If I make container.innerHTML = "Good morning" or anything else it works fine. Any ideas why this happens?

最满意答案

在没有看到你的代码示例的情况下,我会走出一条腿,说你想使用jQuery,特别是.load方法。 它使这样的事情变得非常容易。

<body> <a href="#" id="loadSomePage">load some page</a> <div id="contentArea">content goes here</div> </body> <script> $("#loadSomePage").click(function(){ $("#contentArea").load("http://www.foo.com/content.html"); }); </script>

Without seeing your code sample, I'm going to go out on a limb and say you want to use jQuery, specifically the .load method. It makes stuff like this ridiculously easy.

<body> <a href="#" id="loadSomePage">load some page</a> <div id="contentArea">content goes here</div> </body> <script> $("#loadSomePage").click(function(){ $("#contentArea").load("http://www.foo.com/content.html"); }); </script>

更多推荐

本文发布于:2023-08-08 00:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466694.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:页面   动态   html   page   dynamically

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!