- HTML标签方式:使用
<iframe>标签,其中src属性指定要嵌入的页面地址。
<iframe src="http://www.example.com"></iframe>
- JavaScript方式:使用JavaScript代码动态创建iframe元素,并设置其src属性。
var iframe = document.createElement('iframe');
iframe.src = 'http://www.example.com';
document.body.appendChild(iframe);
- jQuery方式:使用jQuery库的
$()函数创建iframe元素,设置其src属性,并插入到页面中。
$('<iframe>', {
src: 'http://www.example.com'
}).appendTo('body');
- AngularJS方式:使用AngularJS框架的
ng-include指令,将要嵌入的页面地址作为参数传入。
<div ng-include="'http://www.example.com'"></div>
- React方式:使用React框架的
<iframe>组件,设置其src属性。
<iframe src="http://www.example.com"></iframe>