如何使用jQuery创建iframe,并在页面上显示? [英] How to create an iframe using jQuery, and display on page?

查看:114
本文介绍了如何使用jQuery创建iframe,并在页面上显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$(document).ready(function(){
    $('#button').click(function(){
       $('.accordion').load('<iframe src="google.com' frameborder="0" scrolling="no" id="myFrame"></iframe>');
    });
});

这无法显示google.com的iframe.谁能提供有关修复方法的建议?

This can't display the iframe of google.com. Can anyone provide suggestions on how to fix it?

推荐答案

jQuery的加载函数是"用这种方式.除其他外,它以URL作为参数,并从该URL加载响应.

jQuery's load function isn't used this way. It takes a URL as a parameter, among others, and loads the response from that URL.

如果您尝试创建iframe DOM元素,请使用 jQuery 函数执行并将其附加到您想要的位置:

If you are trying to create an iframe DOM element, use the jQuery function to do this and append it where you want:

$('<iframe src="http://google.com" frameborder="0" scrolling="no" id="myFrame"></iframe>')
     .appendTo('.accordion');

$('<iframe>', {
   src: 'http://google.com',
   id:  'myFrame',
   frameborder: 0,
   scrolling: 'no'
   }).appendTo('.accordion');

这篇关于如何使用jQuery创建iframe,并在页面上显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆