rscandc0
asked on
Trying to extract from an Iframe containg a php doc with Firefox JS
I chose JS as the are but it could be HTML or other areas (depends on the solution)
I need to extract a string from a document sitting in an Iframe. The doc is loaded from the same directory as the page I am accessing the Iframe from and I donr get Access Denied (yet). I need this to work with both IE and Firefox at least. The scenario is
I call a function from JS in the body of the "main" document to extract data. The frame is named and has id (both the same)
This code works with IE but not with Firefox
var myhtml;
var timebit;
var timebit1;
var temp = new Array();
var index
myhtml=window.frames["smar ttime"].do cument.bod y.innerHTM L;
index=myhtml.indexOf("ET")
it also works if I use frames["smarttime"] etc.
I have tried various constructs which result in an undefined error or just nothing extracted. I have moved stuff around to ensure the frame was loaded before the script was executed (dont know why cos IE works) and I have used scripts I have found on the net. (which I can provide if required, however the issue is not to discover what doesnt work but what does.) I dont really know whether JS (or whatever) treats the content of the iframe or even the iframe itself as object or frame or what. This is my first time using an iframe (maybe the last) so I dont know really what info is required to solve this, but can provide more if necessary. I can using a construct I found here get the frame content rendered into a window but this is not OK for me as I need to parse the source and cant have windows popping up in the app. I think I would eventaully get there but time is of the essence so I reckon its worth more than difficult
Cheers if anyone can help Id be grateful.
I need to extract a string from a document sitting in an Iframe. The doc is loaded from the same directory as the page I am accessing the Iframe from and I donr get Access Denied (yet). I need this to work with both IE and Firefox at least. The scenario is
I call a function from JS in the body of the "main" document to extract data. The frame is named and has id (both the same)
This code works with IE but not with Firefox
var myhtml;
var timebit;
var timebit1;
var temp = new Array();
var index
myhtml=window.frames["smar
index=myhtml.indexOf("ET")
it also works if I use frames["smarttime"] etc.
I have tried various constructs which result in an undefined error or just nothing extracted. I have moved stuff around to ensure the frame was loaded before the script was executed (dont know why cos IE works) and I have used scripts I have found on the net. (which I can provide if required, however the issue is not to discover what doesnt work but what does.) I dont really know whether JS (or whatever) treats the content of the iframe or even the iframe itself as object or frame or what. This is my first time using an iframe (maybe the last) so I dont know really what info is required to solve this, but can provide more if necessary. I can using a construct I found here get the frame content rendered into a window but this is not OK for me as I need to parse the source and cant have windows popping up in the app. I think I would eventaully get there but time is of the essence so I reckon its worth more than difficult
Cheers if anyone can help Id be grateful.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry about the typo myHTML
Here is code, I used to test.
<body onload does work with IE, and FF.
Please check it out.
<html>
<head>
<title>Frame3 Access </title>
<script language="javascript">
function onLoad() {
alert (top.ifr3.window.document. body.inner HTML);
return;
}
</script>
</head>
<body onLoad="onLoad();">
<iframe id="ifr1" width="100" height="100" title="iframe 1">
</iframe>
<iframe id="ifr2" height="100" width="100" title="Iframe 2">
</iframe>
<iframe id="ifr3" name="ifr3" height="100" width="100" title="iframe 3" src="form.htm">
</iframe>
</body>
</html>
<!--- FORM.HTM -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test Form </title>
</head>
<body>
<form name="MyForm">
<select size="1" id="Select1" name="selectMonth" disabled="true">
<option selected value="Jan">Jan</option>
<option value="Feb">Feb</option>
<option value="Mar">Mar</option>
<option value="Apr">Apr</option>
<option value="May">May</option>
<option value="Jun">Jun</option>
<option value="Jul">Jul</option>
<option value="Aug">Aug</option>
<option value="Sep">Sep</option>
<option value="Oct">Oct</option>
<option value="Nov">Nov</option>
<option value="Dec">Dec</option>
</select>
<select size="1" name="yearclosed" disabled="true">
<option>2005</option>
<option>2006</option>
<option>2007</option>
<option>2008</option>
<option>2009</option>
<option>2010</option>
</select>
</form>
</body>
</html>
Here is code, I used to test.
<body onload does work with IE, and FF.
Please check it out.
<html>
<head>
<title>Frame3 Access </title>
<script language="javascript">
function onLoad() {
alert (top.ifr3.window.document.
return;
}
</script>
</head>
<body onLoad="onLoad();">
<iframe id="ifr1" width="100" height="100" title="iframe 1">
</iframe>
<iframe id="ifr2" height="100" width="100" title="Iframe 2">
</iframe>
<iframe id="ifr3" name="ifr3" height="100" width="100" title="iframe 3" src="form.htm">
</iframe>
</body>
</html>
<!--- FORM.HTM -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test Form </title>
</head>
<body>
<form name="MyForm">
<select size="1" id="Select1" name="selectMonth" disabled="true">
<option selected value="Jan">Jan</option>
<option value="Feb">Feb</option>
<option value="Mar">Mar</option>
<option value="Apr">Apr</option>
<option value="May">May</option>
<option value="Jun">Jun</option>
<option value="Jul">Jul</option>
<option value="Aug">Aug</option>
<option value="Sep">Sep</option>
<option value="Oct">Oct</option>
<option value="Nov">Nov</option>
<option value="Dec">Dec</option>
</select>
<select size="1" name="yearclosed" disabled="true">
<option>2005</option>
<option>2006</option>
<option>2007</option>
<option>2008</option>
<option>2009</option>
<option>2010</option>
</select>
</form>
</body>
</html>
ASKER
Thanks for your help
ASKER
So cheers