jquery - access parent div from inside iframe -


have div inside have iframe - on button(within iframe) click redirect page on domain - here on new page - onload event when

$('#parentdiv',window.parent.document).hide(); 

getting error: permission denied access property 'document

here redirected page on domain - see redirected page , script tags inside <iframe> -

this not possible javascript security, has withdrawn support such executions. url of iframe should in same domain document, , includes subdomain.

example:

www.host.com -> my.host.com [not working!] www.host.com -> www.host.com [works!] www.host.com -> host.com [not working!] host.com -> host.com [works!] 

the idea avoid injecting code of others.

but can things...with ajax?: yes!

if need data external server, have this: ideally, external server headers have:

access-control-allow-origin: * access-control-allow-credentials: true 

and use jquery code:

$.ajax({      url: 'https://www.host.com/',     data: mydata,     type: 'get',     crossdomain: true,     datatype: 'jsonp',     success: function() { alert("success"); },     error: function() { alert('failed!'); },     beforesend: setheader }); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -