is it possible change or append hyperlink in a iframe?
Here is my code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
function changelinks(iframe){
var as = iframe.contentDocument.getElementsByTagName('a');
for(i=0;i<as.length;i++){
as[i].setAttribute('href',"http://www.yahoo.com");
}
}
</script>
</head>
<body>
<iframe src="http://www.google.com" onload="changelinks(this)"></iframe>
My goal is when click on any link under iframe, destination url will be www.yahoo.com.
any suggestion is welcome. UPDATE I fetch website in iframe not located in my server.