我想在css动画扩展iframe中打开一个链接。
我的问题:当我点击链接时,href / url没有加载。我可以触发iframe的css动画。 (也许js会覆盖href?)
在某些时候,我将请求分成两个测试链接:一个加载扩展iframe,另一个加载页面到现在可见的iframe,这是有效的。但是,只要我将两个链接放在一起,网址就不会加载。
我尝试了很多其他的东西并搜索了很多jQuery-Plugins,但还没有找到合适的解决方案。 在此先感谢您的帮助!
这是现场演示的小提琴: https://jsfiddle.net/10jew169/2/
这是滑动iframe的CSS:
/*iframe styling*/
#slideiniframe {
height: 100%;
position: fixed;
border: none;
margin: 0;
top: 0;
right: 0;
background: url(img/preloader.gif) #d8d8d8 center no-repeat;
max-width: 800px;
}
/*iframe animation*/
.hide {
overflow: hidden;
width: 0%;
padding-top: 0;
padding-bottom: 0;
margin-top: 0;
margin-bottom: 0;
-moz-transition-duration: 0.3s;
-webkit-transition-duration: 0.3s;
-o-transition-duration: 0.3s;
transition-duration: 0.3s;
-moz-transition-timing-function: cubic-bezier(0, 1, 0.5, 1);
-webkit-transition-timing-function: cubic-bezier(0, 1, 0.5, 1);
-o-transition-timing-function: cubic-bezier(0, 1, 0.5, 1);
transition-timing-function: cubic-bezier(0, 1, 0.5, 1);
}
.show {
transition-duration: 0.3s;
-moz-transition-duration: 0.3s;
-webkit-transition-duration: 0.3s;
-o-transition-duration: 0.3s;
transition-timing-function: ease-in;
-moz-transition-timing-function: ease-in;
-webkit-transition-timing-function: ease-in;
-o-transition-timing-function: ease-in;
width: 50%;
overflow: hidden;
}
身体的html与js / jquery一起激活css动画:
<!--article preview with two links to the iframe-->
<div class="post-content">
<h2>The World's Coolest Passport Stamps</h2>
<div class="body-text">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>
<p><a class="read_more" href="http://travel-and-leisure-yahoopartner.tumblr.com/post/142022520144/the-worlds-coolest-passport-stamps" target="articleiframe">Keep reading</a></p>
<!--full article in iframe-->
<iframe id="slideiniframe" class="hide" name="articleiframe">
<p>Your browser does not support iframes.</p>
</iframe>
<!--slide in animated when clicked on link and hide when clicked elsewhere-->
<script>
$('.read_more').click(function(){
$('#slideiniframe').toggleClass('show').toggleClass('hide');
return false;
});
$(window).ready(function(){
$('html').click(function(){
$('#slideiniframe').addClass('hide').removeClass('show');
});
});
</script>
答案 0 :(得分:0)
您需要将href
值传递给iFrame的src
属性。
$('.read_more').click(function() {
$('#slideiniframe').prop('src', $(this).prop('href'))
$('#slideiniframe').toggleClass('show').toggleClass('hide');
return false;
});