Wednesday 15 August 2012

javascript - Iframe Alt Text When Iframe load error for X-Frame-Options:SAMEORIGIN | DENY -



javascript - Iframe Alt Text When Iframe load error for X-Frame-Options:SAMEORIGIN | DENY -

i need show few iframes in angular app.

for , html

<iframe ng-src="{{iframeobj.iurl}}" frameborder="0"></iframe>

but when iurl not allowed in iframes when x-frame-options:sameorigin or deny

then iframe not come , , natural not come.

but want show alternative text when iframe not load correctly. image tag has , alt attribute.

i need way show alt text when iframe can not load.

angularjs , plain javascript solution desired.

thanks in advance.

i have found solution problem:

the thought set onload event before set src.

you can seek code:

document.getelementsbytagname('iframe').onload=function(){ try{ var win=this.contentwindow; win.closed && error_function(); }catch(e){ error_function(); } };

check here how works: http://jsfiddle.net/tec6y2y9/1/

note: on fiddle, made changes show works! error_function() fictional function show set code in case of failure!

i hope works you.

javascript jquery angularjs iframe x-frame-options

No comments:

Post a Comment