I have iframe created and it has no src
at the beginning. When I click on a link, for example, the result from Google search, that link should try to open in that iframe. Not in the tab that I am currently browsing.
$(document).ready(function () {
$('<div />', {
id: 'firster',
style: 'position: fixed; top: 0; bottom: 0; right: 0; max-width: 500px; z-index: 120;'
}).appendTo('body');
$('<iframe />', {
name: 'frame1',
id: 'frame1',
src: ''
})
.css({
'height': '100%',
'width': '450px'
}).appendTo('#firster');
$("a").click(function(e) {
$("#frame1").attr("src", window.location.protocol + '//' + window.location.host + $(this).attr("href"));
return false;
})
});
What I expect is to open that url ( I concated the protocol host and url ), it just does not open.
Element status before clicking on link:
And element status after clicking on link:
How to fix this? Any way around it?
Edit part:
This is what im getting periodically in console:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://accounts.google.com/ServiceLogin?passive=1209600&osid=1&continue=https://notifications.google.com/u/0//idv2&followup=https://notifications.google.com/u/0//idv2&authuser=0. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).