Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

append element in head of an iframe using jquery

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);
like image 875
Lalchand Avatar asked Feb 14 '11 08:02

Lalchand


2 Answers

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" />

like image 122
DKSan Avatar answered Nov 18 '22 05:11

DKSan


well, you can check with this:

$('#tabsFrame').contents().find("head")[0].appendChild(cssLink);
like image 41
animacom Avatar answered Nov 18 '22 04:11

animacom