Hi guys I have created these two pieces of code in JSFiddle: First code and Second code. If you take a look at the second code, I am trying to close the iframe when a url in the iframe is clicked.
Thank you in advance
Hi guys I have created these two pieces of code in JSFiddle: First code and Second code. If you take a look at the second code, I am trying to close the iframe when a url in the iframe is clicked.
Thank you in advance
It looks like you do not have CORS access, so you can't click on anything on the <iframe src='page'>
using JavaScript.
$(document).ready(function(){
var ifc = $('#iframecontainer'), ifr = ifc.find('iframe');
var btn = $('#button');
ifc.fadeIn('slow', function(){
ifc.css('background', "url('http://www.calgaryramsrugby.com/images/ajax-loader.gif')");
ifr.attr('src', 'http://coinurl.com/get.php?id=22615').load(function(){
ifc.css('background', '#fff');
btn.click(function(){
ifc.hide();
alert("Can't find attributes in iframe through JavaScript without CORS access");
});
});
});
btn.mouseover(function(){
btn.css('cursor', 'pointer');
});
});
If it hides your Element it won't open the link inside the iframe
. http://jsfiddle.net/PD82A/4/
you're not allowed to access parent.document in this case of a iframe without using a workaround.
you get a CORS error because of the security settings.
SecurityError: Blocked a frame with origin "http://fiddle.jshell.net" from accessing a cross-origin frame.
The workaround works because you include another iframe in your iframe that comes from the same origin as the parent and thus gives you access to the main window