实现了iframe的页面跳转的功能

  之前没有接触过iframe的相关功能,最近看到项目中基本上都是用iframe嵌套子页面,于是自己想编写实现这个过程,为以后的工作提供便利.

  main页面

  

<!DOCTYPE html><html><head lang="en">    <meta charset="UTF-8">    <title></title>    <link rel="stylesheet" href="css/main.css"/>    <script src="js/jquery-1.11.3.min.js"></script></head><body>    <header id="top">        <ul>            <li id="foot1">首页</li>            <li id="foot2">子页面1</li>            <li id="foot3">子页面2</li>            <li id="foot4">子页面3</li>        </ul>    </header>    <section id="main">        <iframe frameborder="0" src="01.html"></iframe>    </section>    <footer id="foot">&copy;mumu</footer>    <script src="js/jsss.js">    </script></body></html>

js中的代码:
$(function(){    $("#foot2").click(function(){        console.log("safd");        $("iframe").attr("src","02.html");    });    $("#foot3").click(function(){        console.log("safd");        $("iframe").attr("src","03.html");    });    $("#foot4").click(function(){        console.log("safd");        $("iframe").attr("src","04.html");    });    $("#foot1").click(function(){        console.log("safd");        $("iframe").attr("src","01.html");    })});

子页面1:
<!DOCTYPE html><html><head lang="en">    <meta charset="UTF-8">    <title></title></head><style>    body{        width: 1200px;        margin: 0 auto;    }</style><body>    子页面111111111111111111111111111111111111111</body></html>
子页面2:
<!DOCTYPE html><html><head lang="en">    <meta charset="UTF-8">    <title></title></head><style>    body{        width: 1200px;        margin: 0 auto;    }</style><body>    子页面222222222222222222222222222222222222222</body></html>
子页面3:
<!DOCTYPE html><html><head lang="en">    <meta charset="UTF-8">    <title></title></head><style>    body{        width: 1200px;        margin: 0 auto;    }</style><body>    子页面33333333333333333333333333333</body></html>
子页面4:
<!DOCTYPE html><html><head lang="en">    <meta charset="UTF-8">    <title></title></head><style>    body{        width: 1200px;        margin: 0 auto;    }</style><body>    子页面444444444444444444444444444444444</body></html>以上没有布上css样式.自己脑补。
时间: 2024-08-07 16:46:50

实现了iframe的页面跳转的功能的相关文章

完善用户体验: 活用window.location与window.open解决页面跳转问题

原文地址: JavaScript Redirects and window.open原文日期: 2014年08月27日翻译日期: 2014年08月31日翻译人员: 铁锚 (译者注: 本文解决的是按 Ctrl键时使用JS打开新页面的问题) 在简化的HTML5规范中,允许在 A 标签内包含多个 DIV 和/或其他块级元素. 现在只要用 <a> 标签包住块元素,就能搞定原来需要用JavaScript来监听并调用 window.location 实现页面跳转(redirect)功能.但使用<a&

phonegap+极光推送+页面跳转

最近公司使用sencha touch开发app需要实现推送的功能,本渣花了一周的时间才把安卓和ios都实现了推送已经跳转页面的功能.晚上关于推送的资料很少,关于推送后页面跳转的资料就更少了,所以这里记录一下怕以后忘了. 首先是安卓的实现方式(首先需要在极光推送上面去注册一个账号): 1:用sencha CMD创建st应用: sencha -sdk D:\java\sencha-touch\touch-2.3.1 generate app FirstApp ../FirstApp 这样就生成了一个

iframe 的使用和登陆退出的实现——整个页面跳转

iframe中如果只是页面跳转的话,我们依然只是部分的加载的了,为了实现整个页面的所有内容跳转,下面提供了整个页面跳转的方法. iframe例子 1.总的iframe页面(访问就访问这个)  all.html <frameset rows="45%,*" frameborder=0 framespacing=10> <frame src="top.html" noresize/> <frameset cols="20%,*&q

关于使用iframe嵌套页面的跳转方式

一.背景A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,在D中跳转页面的写法区别如下. 二.JS跳转window.location.href.location.href 本页面跳转,D页面跳转 parent.location.href 上一层页面跳转,C页面跳转 top.location.href 最外层页面跳转,A页面跳转 三.链接或者formD页面中有form <form>: form提交后D页面跳转 <form target="

iframe中请求页面而session失效时页面跳转问题

iframe中请求页面而session失效时页面跳转问题 分类: Web2009-12-11 15:01 656人阅读 评论(0) 收藏 举报 sessioniframejsp 有时候做了就忘了,我记得曾经在学校里老师教过这个问题,可一时就是想不起来,不过终于搜到了这么一篇文章,先记下来以便下次再得了遗忘症. 访问相关jsp页面时,往往要先判断用户session是否失效,以便决定是继续业务,还是跳转到登录页面.这个事情我们通常是用过滤器来实现的.由过滤器判断session是否失效,由此来决定请求

使用iframe框架后的页面跳转时目标页面变为iframe的子页面的问题

<frameset rows="4,200,10,*,120" cols="*" framespacing="0" frameborder="no" border="1" > <frame src=""/> <frame src="<%=practiceInfoSrc %>" id="practiceInfo&quo

解决iframe重定向让父级页面跳转

原文:http://www.jb51.net/article/40583.htm 有内嵌iframe的页面,当session过期时,点击连接重定向后的跳转会在iframe中跳转,在登录页面中加入下面的代码,就会在最外层页面跳转 原文:http://www.cnblogs.com/JemBai/archive/2011/10/09/2203429.html <script language="JavaScript"> if (window != top) top.locati

iframe嵌套页面中的跳转

简单说一下场景. 假设有A.B.C和D四个JSP页面,D通过iframe嵌套在C中,C通过iframe嵌套在B中,B通过iframe嵌套在A中. 然后现在在D中编写JavaScript代码跳转页面. 在本页面跳转(D页面所在的iframe中跳转) window.location.href = '要跳转的页面路径'; 在上一层跳转(D页面所在iframe的父页面中跳转,即C所在的iframe中跳转) parent.location.href = '要跳转的页面路径'; 如果要在B所在的iframe

js控制页面跳转

1.location.href self.location.href: window.location.href='url':重定向页面并刷新,而window.open('url')只表示打开页面,并不刷新 this.location.href: location.href:以上四种都为本页面跳转 parent.location.href:上一层页面跳转(iframe) top.location.href:最外层页面跳转(iframe) 2.window.history.go(number):