iframe標簽里面的頁面元素只讀,可以通過設置一個只讀的透明div進行遮罩實現。
html代碼:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <style> .mask { position: absolute; width: 100%; height: 100%; z-index: 1; filter: alpha(opacity=0); opacity: 0; background: #ffffff; } </style> <div style="position: relative"> <div class="mask"> </div> <iframe src="http://bbs.csdn.net" width="500px" height="300px" id="ifr"></iframe> </div>
效果: