Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I am trying to acess a form field in an iframe from within the main page and getting Object Expected errors:
<script language="JavaScript1.2" type="text/javascript">
//alert(window.frames['outputFrame'].document));
var s1=window.frames['outputFrame'].document;
var s2=s1.getElementById("head").value; OR var s2=s1.forms[0].head.value;
alert("VAL:::"+s2);
</script>The above gives OBJECT EXPECTED errors. WHAT very very strange to me is if I uncomment the first ALERT line, it works just great !!!!! unable to understand what ALERT has to do with the script !!?
thnx

Not sure about that one. But, I've never seen "OR" used in js before. And, I've only seen the double pipe reperesentation (||) of OR used within a case statement. What is it's purpose within your script? How does the script know which value to use?
Michael J

Sorry bout that ! By saying
"var s2=s1.getElementById("head").value; OR var s2=s1.forms[0].head.value;"
I meant to say, I experimented with both of them (separately) but keep getting the same error..
Another thing, If I dump the above code inside a function and call it, it works but using within the <script> tags, it doesnt :(

Javascript is notorious for giving errors that have absolutely nothing to do with the actual problem. From the little code you posted, the only problem I see is that you have an extra ')' on the first commented out alert statement.
Try using a javascript debugger to step through the code and see where the error is being thrown. For IE, I use Visual Studio.Net, and for Firefox, I use the free Venkman plugin.
Good luck,
-SN

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |