溫馨提示×

iframe寫法有哪些

小億
134
2023-06-09 15:28:03
欄目: 編程語言

  1. HTML標(biāo)簽方式:使用<iframe>標(biāo)簽,其中src屬性指定要嵌入的頁面地址。
<iframe src="http://www.example.com"></iframe>
  1. JavaScript方式:使用JavaScript代碼動(dòng)態(tài)創(chuàng)建iframe元素,并設(shè)置其src屬性。
var iframe = document.createElement('iframe');
iframe.src = 'http://www.example.com';
document.body.appendChild(iframe);
  1. jQuery方式:使用jQuery庫的$()函數(shù)創(chuàng)建iframe元素,設(shè)置其src屬性,并插入到頁面中。
$('<iframe>', {
src: 'http://www.example.com'
}).appendTo('body');
  1. AngularJS方式:使用AngularJS框架的ng-include指令,將要嵌入的頁面地址作為參數(shù)傳入。
<div ng-include="'http://www.example.com'"></div>
  1. React方式:使用React框架的<iframe>組件,設(shè)置其src屬性。
<iframe src="http://www.example.com"></iframe>

0