使用jQuery选项卡刷新加载到iframe中的html
Refresh html that is loaded into iframe with jQuery tab
非常新…
我的网站http://www.daveknispel.com.au是我有问题的地方。
我使用jQuery将html页面加载到带有标签系统的iframe中。这有两个级别,所以在iFrame内的html中使用了类似的选项卡系统。问题是当我在原始页面上切换时,iFrame中的html与切换不会刷新到其初始状态。
Index.html> has |work| |contact| |resume| tabs
在work.html中,位于index.html的iframe中,它有一系列作为标签的图像所以如果你按下TAB键,比如ghostbuster,我的ghostbusters作品集HTML就会出现在框架内。
如果现在你再次按下|work|我想让iframe重置为原来的work.html
不确定这是否清楚,但希望。
// JavaScript Document
$("document").ready(function(){
$('#content > div').hide();
$('#content div:first').show();
$('.nav-wrapper ul li:first').addClass('active');
$('.nav-wrapper ul li a').click(function(){
$('.nav-wrapper ul li').removeClass('active');
$(this).parent().addClass('active');
var currentTab = $(this).attr('href');
$('#content > div').hide();
$(currentTab).fadeIn(400).fadeIn('slow');
return false;
});
});
//index . html <div class="nav-wrapper">
<div class="menu">
<ul>
<li><a class="fill-div" href="#work" onclick="work.html.refresh"><h2>work</h2></a></li>
<li><a class="fill-div" href="#about"><h2>about/contact</h2></a></li>
<li><a class="fill-div" href="#resume"><h2>resume</h2></a></li>
</ul>
</div>
<div id="content">
<div id="work">
<iframe src="work.html" width="860px" height="1380px" frameborder="0" scrolling="no" seamless></iframe>
</div>
<div id="about">
<iframe src="about.html" width="860px" height="1500px" frameborder="0" scrolling="no" seamless></iframe>
</div>
<div id="resume">
<iframe src="resume.html" width="860px" height="1216px" frameborder="0" scrolling="no" seamless></iframe>
</div>
</div>
</div>
//work.html <div class="nav-wrapper">
<div id="content">
<div class="menu2">
<ul>
<div class="frameProject">
<li><a class="fill-div" href="#metro">
<img src="img/metro.jpg" alt="Metropolitan Hotel">
<h3> Metropolitan Hotel </h3></a></li>
<h4> Web, Print & Digital </h4>
</div>
<div class="frameProject">
<li><a class="fill-div" href="#ghostbusters">
<img src="img/ghostbusters.jpg" alt="Ghostbusters">
<h3> Ghostbusters </h3></a></li>
<h4> Title Sequence </h4>
</div>
<div class="frameProject">
<li><a class="fill-div" href="#uep">
<img src="img/uep.jpg" alt="UEP Pty. Ltd.">
<h3> UEP </h3></a></li>
<h4> Website & Build </h4>
</div>
<div class="frameProject">
<li><a class="fill-div" href="#science">
<img src="img/science.jpg" alt="Science Q and A">
<h3> Science Q and A </h3></a></li>
<h4> Logo Design </h4>
</div>
<div class="frameProject">
<li><a class="fill-div" href="#gonski">
<img src="img/gonski.jpg" alt="Gonski Review">
<h3> Gonski Review </h3></a></li>
<h4> Infographic Animation </h4>
</div>
<div class="frameProject">
<li><a class="fill-div" href="#mylife">
<img src="img/mylife.jpg" alt="My Life Network">
<h3> My Life Network </h3></a></li>
<h4> Logo & Web Design </h4>
</div>
<div class="frameProject">
<li><a class="fill-div" href="#gameandwatch">
<img src="img/gameandwatch.jpg" alt="Game and Watch">
<h3> Game and Watch </h3></a></li>
<h4> Design & Programming </h4>
</div>
<div class="frameProject">
<li><a class="fill-div" href="#barnbrook">
<img src="img/barnbrook.jpg" alt="Barnbrook">
<h3> Jonathon Barnbrook </h3></a></li>
<h4> Poster Design </h4>
</div>
<div class="frameProject">
<li><a class="fill-div" href="#cerberus">
<img src="img/cerberus.jpg" alt="Cerberus">
<h3> Cerberus v Hercules </h3></a></li>
<h4> Design </h4>
</div>
<div class="frameProject">
<li><a class="fill-div" href="#whenjooturns">
<img src="img/joo.jpg" alt="When Joo Turns">
<h3> When Joo Turns </h3></a></li>
<h4> Animation </h4>
</div>
<div class="frameProject">
<li><a class="fill-div" href="#allstar">
<img src="img/afl.jpg" alt="All Star Karaoke">
<h3> All Star Karaoke </h3></a></li>
<h4> Animation </h4>
</div>
<div class="frameProject">
<li><a class="fill-div" href="#iamlife">
<img src="img/iamlife.jpg" alt="I am Life - Film">
<h3> I am Life Film </h3></a></li>
<h4> Assistant Director </h4>
</div>
<div class="frameProject">
<li><a class="fill-div" href="#owlfarm">
<img src="img/owl.jpg" alt="Owl Farm">
<h3> Owl Farm </h3></a></li>
<h4> Logo Design </h4>
</div>
</ul>
</div>
<div id="metro">
<iframe src="metro.html" width="840px" height="1216px" frameborder="0" scrolling="yes" seamless></iframe>
</div>
<div id="ghostbusters">
<iframe src="ghostbusters.html" width="840px" height="1216px" frameborder="0" scrolling="yes" seamless></iframe>
</div>
<div id="uep">
<iframe src="uep.html" width="840px" height="1216px" frameborder="0" scrolling="yes" seamless></iframe>
</div>
<div id="science">
<iframe src="science.html" width="840px" height="1216px" frameborder="0" scrolling="yes" seamless></iframe>
</div>
<div id="gonski">
<iframe src="gonski.html" width="840px" height="1216px" frameborder="0" scrolling="yes" seamless></iframe>
</div>
<div id="mylife">
<iframe src="mylife.html" width="840px" height="1216px" frameborder="0" scrolling="yes" seamless></iframe>
</div>
<div id="gameandwatch">
<iframe src="gameandwatch.html" width="840px" height="1216px" frameborder="0" scrolling="yes" seamless></iframe>
</div>
<div id="barnbrook">
<iframe src="barnbrook.html" width="840px" height="1216px" frameborder="0" scrolling="yes" seamless></iframe>
</div>
<div id="cerberus">
<iframe src="cerberus.html" width="840px" height="1216px" frameborder="0" scrolling="yes" seamless></iframe>
</div>
<div id="whenjooturns">
<iframe src="whenjooturns.html" width="840px" height="1216px" frameborder="0" scrolling="yes" seamless></iframe>
</div>
<div id="allstar">
<iframe src="allstar.html" width="840px" height="1216px" frameborder="0" scrolling="yes" seamless></iframe>
</div>
<div id="iamlife">
<iframe src="iamlife.html" width="840px" height="1150px" frameborder="0" scrolling="yes" seamless></iframe>
</div>
<div id="owlfarm">
<iframe src="owlfarm.html" width="840px" height="1216px" frameborder="0" scrolling="yes" seamless></iframe>
</div>
</div>
</div>
你的解决方案有点复杂,但这是一个解决问题的方法。
// JavaScript Document
$("document").ready(function(){
$('#content > div').hide();
$('#content div:first').show();
$('.nav-wrapper ul li:first').addClass('active');
$('.nav-wrapper ul li a').click(function(){
$('.nav-wrapper ul li').removeClass('active');
$(this).parent().addClass('active');
var currentTab = $(this).attr('href');
$('#content > div').hide();
// Added lines. Reset the iframe src to reload the original contents of the iframe.
var iframe = $(currentTab).find('iframe').get(0);
iframe.src = iframe.src;
$(currentTab).fadeIn(400).fadeIn('slow');
return false;
});
});
这可能行得通:
$( "#tabs" ).tabs( "refresh" );
相关文章:
- 重定向iFrame中的父URL
- 如何使用JS/jQuery在另一个网站上显示iframe中的特定内容
- 动态创建的iframe中的window.onerror在lne 0处给出脚本错误
- 通过提示中的循环触发iFrame中的输入按钮(JavaScript)
- iframe中的jQuery查找元素不起作用
- 是否可以添加<脚本>添加'_someTag'到iFrame中的URL
- 从iframe中的子域进行JavaScript跨域访问
- 突出显示页面上嵌入的iframe中的单词
- iframe中的jquery-click元素
- parent和iframe中的Bootstrap.js文件
- 将iframe中的css类应用于主文档
- iframe中的iframe没有滚动
- 如何将事件侦听器添加到跨域iframe中的元素中
- 如何防止iframe中的链接在新选项卡中打开
- 如何清除iframe中的所有内容
- 如何禁用Iframe中的所有单击
- 如果iframe在src(pdf或text)中有非html文档,则iframe中的onload不起作用
- 更改多个 iframe 中的文本框属性
- 如何检查 iframe 中的锚标记是否包含 URL
- 如何使 iframe 中的内容响应式