Difference between revisions of "TYPESCRIPT - Update css of iframe by jquery"
Jump to navigation
Jump to search
Line 14: | Line 14: | ||
private waitForEl(iframe: string, selector: string, count: number, callback: () => void): void { | private waitForEl(iframe: string, selector: string, count: number, callback: () => void): void { | ||
if ( | if ($(iframe).contents().find(selector).length > 0) { | ||
callback(); | callback(); | ||
} else { | } else { |
Latest revision as of 10:33, 18 May 2018
In your .ts file:
private mainFunction(): void {
this.waitForEl('#iframeABC', '.comment', 0, () => {
$('#iframeABC').contents().find('.comment').css({
'border-left': '0px',
'border-right': '0px'
});
console.log('Updated css iframe');
});
}
private waitForEl(iframe: string, selector: string, count: number, callback: () => void): void {
if ($(iframe).contents().find(selector).length > 0) {
callback();
} else {
setTimeout(() => {
count++;
if (count <= 10) {
this.waitForEl(iframe, selector, count, callback);
} else {
return;
}
}, 1000);
}
}