I am loading a url using a iframe and when a user click on any link within the iframe, i am trying to get that href source and append to a url and redirect it.
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<a href="http://www.google.com" >Google</a><br/>
<iframe src="http://example.com" width="100%" height="700px"></iframe>
</body>
</html>
Using below javascript code(found on stack overflow), it is redirecting the links on web page(Ex; google link in the page) but its not redirecting the links in the iframe.
$('a').click(function (event) {
event.preventDefault();
var href = $(this).attr('href')
window.location='http://someurlhere?link=' + href;
});
How to do get the link source from the Iframe and append it to a url and redirect it?