动态加载iframe和关闭

 

 

<!-- rails -->

<%= stylesheet_link_tag 'scaffold' %>

 

  <%= stylesheet_link_tag "tdbank/hoverbox.css" ,media="screen, projection"%>

  <!--[if lte IE 7]>

  <%= stylesheet_link_tag "tdbank/ie_fixes.css" ,media="screen, projection"%>

<![endif]-->

<style type="text/css">

 

  #nav{}

  #iframs{ clear:both}

</style>

<script type="text/javascript">

  var act;

  function Iframe_close(id){

    document.getElementById("iframs").removeChild(document.getElementById("f"+id));

    document.getElementById("iframe_a_"+id).removeChild(document.getElementById("iframe_img_"+id));

    document.getElementById("iframs").removeChild(document.getElementById("iframe_a_"+id));

  };

 

  function CreateIframe(id,url){

    var iframe_a = document.createElement("a");

    iframe_a.href = "javascript:Iframe_close("+id+")";

    iframe_a.id = "iframe_a_"+id;

 

    var iframe_img = document.createElement("img");

    iframe_img.src="/images/tdbank/close.gif";

    iframe_img.align = "right";

    iframe_img.id = "iframe_img_"+id;

 

    var iframe = document.createElement("iframe");

    iframe.setAttribute("id","f"+id);

    iframe.setAttribute("src",url);

    iframe.setAttribute("width",800);

    iframe.setAttribute("height",450);

    document.getElementById("iframs").appendChild(iframe_a);

    document.getElementById("iframe_a_"+id).appendChild(iframe_img);

    document.getElementById("iframs").appendChild(iframe);

  }

</script>

<body>

  <h1>我要申请</h1>

  <div id="nav">

    <ul class="hoverbox">

      <li>

         <a href="javascript:CreateIframe('1','http://localhost:3000/beiju')">

              <img src="/images/poor.s.gif" alt="C账号" />

              <img src="/images/poor.s.gif" alt="C账号" class="preview" />

         </a>

      </li>

      <li>

          <a href="javascript:CreateIframe('2','http://localhost:3000/beiju')">

            <img src="/images/rich.s.gif" alt="B账号" />

            <img src="/images/rich.s.gif" alt="B账号" class="preview" />

          </a>

      </li>

      <li>

          <a href="javascript:CreateIframe('3','http://localhost:3000/beiju')">

            <img src="/images/order.png" alt="订单" />

            <img src="/images/order.png" alt="订单" class="preview" />

          </a>

      </li>

      <li>

          <a href="javascript:CreateIframe('4','/http://localhost:3000/beiju')">

            <img src="/images/your_choice.png" alt="next" />

            <img src="/images/your_choice.png" alt="next" class="preview" />

          </a>

      </li>

    </ul>

  </div>

  <div id="iframs">

  </div>

</body>

 

 

[ie_fixes.css]

/* =Internet Explorer Fixes

----------------------------------------------------------------------*/

 

.hoverbox a

{

position: relative;

}

 

.hoverbox a:hover

{

display: block;

font-size: 100%;

z-index: 1;

}

 

.hoverbox a:hover .preview

{

top: -38px;

left: -50px;

}

 

.hoverbox li

{

position: static;

}

 

 

 

[hoverbox.css]

 

 

 

*

{

border: 0;

margin: 0;

padding: 0;

}

 

/* =Basic HTML, Non-essential

----------------------------------------------------------------------*/

 

a

{

text-decoration: none;

}

 

body

{

background: #fff;

color: #777;

margin: 0 auto;

padding: 50px;

position: relative;

width: 820px;

}

 

h1

{

background: inherit;

border-bottom: 1px dashed #ccc;

color: #933;

font: 17px Georgia, serif;

margin: 0 0 10px;

padding: 0 0 5px;

text-align: center;

}

 

p

{

clear: both;

font: 10px Verdana, sans-serif;

padding: 10px 0;

text-align: center;

}

 

p a

{

background: inherit;

color: #777;

}

 

p a:hover

{

background: inherit;

color: #000;

}

 

/* =Hoverbox Code

----------------------------------------------------------------------*/

 

.hoverbox

{

cursor: default;

list-style: none;

}

 

.hoverbox a

{

cursor: default;

}

 

.hoverbox a .preview

{

display: none;

}

 

.hoverbox a:hover .preview

{

display: block;

position: absolute;

top: -33px;

left: -45px;

z-index: 1;

}

 

.hoverbox img

{

background: #fff;

border-color: #aaa #ccc #ddd #bbb;

border-style: solid;

border-width: 1px;

color: inherit;

padding: 2px;

vertical-align: top;

width: 100px;

height: 75px;

}

 

.hoverbox li

{

background: #eee;

border-color: #ddd #bbb #aaa #ccc;

border-style: solid;

border-width: 1px;

color: inherit;

display: inline;

float: left;

margin: 3px;

padding: 5px;

position: relative;

}

 

.hoverbox .preview

{

border-color: #000;

width: 200px;

height: 150px;

}

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值