IFRAME?在不离开的情况下将动态信息放入网络

时间:2018-02-22 09:22:35

标签: html css iframe

我有一个网页,我有一个旁边的菜单(用于信息或小部件之间的navegation,我尚未决定),旁边有我的内容信息。

好吧,我想要的是通过点击链接,它会触发内容的iframe或其他内容。

我的意思是:我不想加载另一个页面,我想永远保持相同的主页面,因为我有一个音频播放器,我不希望它每次加载另一个页面时更改一首新歌

所以,我尝试使用iframe,但它没有调整内容,所以如果某些页面的高度不同,那么它就不会显示一些,那么如果其他的很短,那么将是一个空白之间的空白内容和页面结尾...

我也搜索了javascript解决方案,但我不理解它,并且无法使其正常工作。

好吧,让我们说这是主页面,我想在开始时没有加载任何内容或者X网页,这没问题。

但是当我点击游戏时我想加载另一个页面(我在这个代码之后发布)并且适合高度。

aside {
  width:15%;
  display: inline-block;
  vertical-align: top;
  margin-top: 20px;
  margin-bottom: 20px;
}

aside > div:not(#marcador) {
  background-color: rgb(40, 44, 47);
  border-radius: 15px;
  box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.055);
  color: silver;
  display: block;
  margin-top: 5px;
  margin-right: -15px;
  font-family: "Press Start 2P";
  font-size: 0.7em;
  line-height: 10px;
  padding: 10px;
  padding-right: 20px;
}

#marcador>ul>li{
  margin-bottom:5px;
}

#marcador li> div {
    font-size: 0.9em;
  opacity: 0;
    display: block;
  
  -moz-transition: opacity 1.2s ease-in-out;
  -o-transition: opacity 1.2s ease-in-out;
  -webkit-transition: opacity 1.2s ease-in-out;
  transition: opacity 1.2s ease-in-out;
}

#marcador li:hover > div {
  opacity: 1;
  padding-left: 20px;
  margin-left: 0;
}

#marcador li> div >ul >li {
  max-height: 0;
  transition: all 0.5s;
}
#marcador li:hover> div >ul >li {
  max-height: 40px;
  margin-top:5px;
}

#marcador li:hover{
  max-height: 500px !important;
}

#marcador li:hover > a {
  display: block;
  opacity: 1;
  visibility: visible;
}

#marcador ul {
  margin: 0;
  padding: 0;
  list-style-type: none;
  position: static;
}

#marcador ul li > a {
  background-color: rgb(40, 44, 47);
  border-radius: 15px;
  box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.055);
  color: silver;
  display: block;
  margin-right: -15px;
  font-family: "Press Start 2P";
  font-size: 0.7em;
  line-height: 10px;
  padding: 15px;
  padding-left: 35px;
}

#marcador ul ul {
  padding: 0;
  margin: auto;
}

#marcador ul ul a {
  margin-left: 20px;
  background-color: dimgray;
}

#marcador ul ul ul a {
  margin-left: 40px;
  background-color: gray;
  color: black;
}

#marcador img {
  float: left;
  vertical-align: middle;
  display: inline-block;
  opacity: 0;
  position: absolute;
  visibility: hidden;
  margin-left: -20px;
}

#marcador li:hover > a > img {
  opacity: 1;
  visibility: visible;
}

#marcador a:hover {
  color: orange;
}

#ifrm{
  width:80%;
  display:inline-block;
}

iframe{
  width:100%;
}
<aside>
                <div id="marcador">
                    <ul>
                        <li>
                            <a><img src="Recursos/Select.png"/>INDEX</a>
                        </li>

                        <li>
                            <a><img src="Recursos/Select.png"/>Games</a>
                            <div>
                                <ul>

                                    <li>
                                        <a><img src="Recursos/Select.png"/>Sega</a>
                                    </li>

                                    <li>
                                        <a class=ult><img src="Recursos/Select.png"/>Arcade</a>
                                    </li>
                                    
                                    <li>
                                        <a><img src="Recursos/Select.png"/>Nintendo</a>
                                        <div>
                                            <ul>
                                                <li>
                                                    <a><img src="Recursos/Select.png"/>SNES</a>
                                                </li>

                                                <li>
                                                    <a class=ult><img src="Recursos/Select.png"/>NES</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </li>

                        
                    </ul>
                </div>

    
    
    <div class="example">
              AUDIO PLAYER HERE
                    </div>
                
                
            </aside>
            
            
            
          <div id="ifrm">
    <iframe src="WelcomeInfo.html" frameborder="0"> </iframe>
</div>

点击旁边栏中的链接,然后将其加载到iframe

section {
  margin-top: 20px;
  margin-bottom: 20px;
  background-color:beige;
  border-radius: 15px;
  padding: 10px;
  color: black;
  display:inline-block;
  width: 100%;

}

article {
  overflow: hidden;
}

article img{
  width: 30%;
  float:right;
  margin-left: 10px;
}
<section>
                <h1>Lorem cabecera ipsum</h1>
                <article>
                    <figure><img alt="Contruccion" src="Recursos/man-at-work-daisy.svg"/></figure>
                    <p>Ésta página <a href="http://google.es">esta</a> en lorem construcción ipsum, tengan paciencia para ver el final. dejo al lado una señal de construcción por si no ha quedado claro, que hay mucha gente despistada en este mundo</p>

                    <p>
                      
        
                        
                    </p>   
                    <p>
                        Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,     
                    </p>   
                   

                </article>

            </section>

1 个答案:

答案 0 :(得分:0)

&#13;
&#13;
function a() {
var iframe=document.createElement("iframe");
iframe.setAttribute("id","iframe");
iframe.setAttribute("class","iframe");
iframe.setAttribute("src","page you want")
document.body.appendChild(iframe);
}
&#13;
<div onclick="a()">ShowIframe</div>
&#13;
&#13;
&#13;