Here's my html/javascript. Below there are two if statements that I've tried. I used indexof to get the text between the tags. Also tried href == to use the href= contents. Both do not work.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>pb</title>
<script type="text/javascript">
function call() {
alert("Called!");
var allAnc = document.getElementById("d").contentDocument.getElementsByTagName("a");
for (var i = 0; i < allAnc.length; i++) {
if (allAnc[i].href.indexOf("Flag") > 0) {
alert("Found link by indexof, Trying to click!");
(allAnc[i]).click();
break;
}
if (allAnc[i].href == "javascript:flag.closeit()") {
alert("Found link by href, Trying to click!");
(allAnc[i]).click();
break;
}
}
}
</script>
</head>
<body>
<input id="Button1" type="button" onclick="call()" value="button" />
<iframe id="d" src="sourceurl.html" width="100%" height=700"></iframe>
</body>
</html>
Here is the link inside the iframe I am trying to click:
<a style="text-align: left;" href="javascript:flag.closeit()" title="Flag">Flag</a>