I have a webpage i download and put into an iframe, to get the contents of a div off of the page. When I get the text from the div and compare it to a string it does not show the variable(which is now the text of a div from the iframe) as a string. I don’t know what the webpage uses to populate the div with the text. How can I make the variable a into a string to compare it within an if statment?
<html>
<head>
<script type="text/javascript">
function init(){
var frame = document.getElementById("frame");
frame.src = "saved.html";
var innerDoc = frame.contentDocument || frame.contentWindow.document;
var divs = innerDoc.getElementsByTagName("div");
if (divs.length == 83) {
a = divs[34].innerHTML;
}
else {
a = divs[33].innerHTML;
}
a = a.split(' ').join('');
a = a.replace("<b>", "");
a = a.replace("</b>", "");
alert(a);
if (a == "Text") {
alert("same");
}
}
</script>
</head>
<body onload="init();">
<iframe id="frame"></iframe>
</body>
</html>
I have figured otu the way to do this. create a textinput and place the variable as the value and retrieve the value of the text input object.