append元素在iframe的头部使用jquery [英] append element in head of an iframe using jquery

查看:177
本文介绍了append元素在iframe的头部使用jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用jquery将样式表(css)链接附加到iframe的头部。
i尝试使用以下代码但不工作。

  $('#tabsFrame')。contents (head)。append(cssLink); 


解决方案

我用来将数据附加到iframe这行代码



$('body',window.frames [target] .document).append(data);



在这种情况下,此行如下所示:



$ ('head',window.frames ['tabsFrame']。document).append(cssLink);



向iframe添加< head>< / head> ,并将var cssLink更改为



cssLink ='< link href =cupertino_1.4 / css / cupertino / jquery-ui-1.8.7.custom.csstype =text / css rel =Stylesheetclass =ui-theme/>


i want to append a style sheet(css) link to the head of an iframe using jquery . i tried with the following code but not working.

$('#tabsFrame').contents().find("head").append(cssLink);

解决方案

i am used to append data to an iframe by using this line of code

$('body', window.frames[target].document).append(data);

In your case, this line would look like this

$('head', window.frames['tabsFrame'].document).append(cssLink);

EDIT:

Add <head></head> to the iframe and change your var cssLink to

cssLink = '<link href="cupertino_1.4/css/cupertino/jquery-ui-1.8.7.custom.css" type="text/css" rel="Stylesheet" class="ui-theme" />

这篇关于append元素在iframe的头部使用jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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