我有四个链接在同一页面上的iframe上打开。我的问题是iframe占用页面加载的空间,我希望它将保持隐藏,直到任何链接被点击coz在小屏幕尺寸同一页面是在页面加载上加载iframe,因为它在大屏幕尺寸下运行良好。请帮我解决这个问题。
以下是我打开iframe的代码:
<ul class="thumbnails">
<li class="span2">
<h6>DELHI :</h6>
A-21/13,Naraina Industrial Area,
Phase II,
New Delhi - 110028.
Tel. No. : 011 - 49807100 / 101
<a href="https://maps.google.co.in/maps?f=q&source=s_q&hl=en&geocode=&q=Pearl+Academy+of+fashion,+CH+Girdhari+Lal+Marg,+Naraina+Industrial+Area,+Naraina,+Delhi&aq=0&oq=Pearl+Academy+Of+Fashion+de&sll=20.984928,82.752628&sspn=61.071168,79.013672&ie=UTF8&hq=Pearl+Academy+of+fashion,+CH+Girdhari+Lal+Marg,+Naraina+Industrial+Area,+Naraina,+Delhi&t=m&ll=28.648453,77.146039&spn=0.011298,0.037293&z=15&output=embed" target="frame">Click Here To View Map</a></li>
<li class="span2">
<h6>NOIDA :</h6>
B-25,Sector - 59,
Noida- 201301, UP.
Tel. No. : 0120 - 4904000
<a href="https://maps.google.com/maps?f=q&source=embed&hl=en&geocode=&q=B-25,Sector+-+59,+Noida-+201301+UP.&sll=37.0625,-95.677068&sspn=50.244827,79.013672&ie=UTF8&hq=&hnear=Sector+59,+NOIDA,+Gautam+Buddha+Nagar,+Uttar+Pradesh,+India&t=m&ll=28.610219,77.367697&spn=0.022605,0.074587&z=14&iwloc=A&output=embed" target="frame">Click Here To View Map</a></li>
<li class="span2">
<h6>CHENNAI :</h6>
82,Sterling Road,
Nungambakkam,(Opposite Loyola College),
Chennai - 600034
Tel. No. : 044-42664445 /46/49/50, 43447900
<a href="https://maps.google.co.in/maps?f=q&source=s_q&hl=en&geocode=&q=Pearl+Academy+Of+Fashion,+Sterling+Rd,+Nungambakkam,+Chennai,+Tamil+Nadu&aq=0&oq=Pearl+Academy+Of+Fashion,+Chennai&sll=13.065034,80.239013&sspn=0.008121,0.009645&ie=UTF8&hq=Pearl+Academy+Of+Fashion,&hnear=Sterling+Rd,+Nungambakkam,+Chennai,+Tamil+Nadu&t=m&ll=13.065516,80.239592&spn=0.006271,0.018647&z=16&iwloc=A&output=embed" target="frame">Click Here To View Map</a></li>
<li class="span2">
<h6>JAIPUR :</h6>
SP-38A,RIICO Industrial Area,
Delhi Road,Kukas,
Jaipur-302028.
Tel. No. : 01426 - 414800, 227515, 227616, 227617
<a href="https://maps.google.co.in/maps?f=q&source=s_q&hl=en&geocode=&q=Pearl+Academy+Of+Fashion,+Jaipur+city+office,+Rajasthan&aq=&sll=25.845253,74.840307&sspn=7.677536,9.876709&ie=UTF8&hq=Pearl+Academy+Of+Fashion,+Jaipur+city+office,&hnear=Rajasthan&t=m&cid=16689440355655361409&ll=27.527758,76.783447&spn=2.922529,9.547119&z=7&iwloc=A&output=embed" target="frame">Click Here To View Map</a></li>
</ul>
<span style="color: #e15b1f;">For more information contact:<a href="#"> counsellor@pearlacademy.com</a>, Toll Free No. 1800 103 3005</span>
这里是同一页面上的iframe:
<div style="display:none;"><iframe name="frame" src="#" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="870" height="300"></iframe></div>
答案 0 :(得分:2)
现在您可以执行此操作:focus
就像这样
<强>的CSS 强>
.frame_div{
border:solid 1px red;
width:300px;
display:none;
}
.frame_div iframe{
height:200px;
width:300px;
background:green;
}
.click_iframe{
display:inline-block;
vertical-align:top;
}
.click_iframe:focus + div{
display:block;
}
<强> HTML 强>
<ul class="thumbnails">
<li class="span2">
<a href="#" target="frame" class="click_iframe">Click Here To View Map</a>
<div class="frame_div"><iframe name="frame" src="#" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="870" height="300"></iframe></div>
</li>
</ul>
的 Live Demo 强> 的
答案 1 :(得分:2)
您可以在ul:
中添加onclick事件<ul class="thumbnails" onClick="document.getElementById('frame').parentNode.style.display=''">
假设您的iframe ID为“frame”:
<div style="display:none;"><iframe name="frame" id="frame" src="#" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="870" height="300"></iframe></div>