Computing.Net > Forums > Web Development > Javascript weird problem

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Javascript weird problem

Reply to Message Icon

Name: gaucho
Date: August 8, 2005 at 06:31:19 Pacific
OS: Windows 98
CPU/Ram: PII 333, 128 Mb
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: August 8, 2005 at 06:49:46 Pacific
Reply:

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


0

Response Number 2
Name: gaucho
Date: August 8, 2005 at 07:02:11 Pacific
Reply:

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 :(


0

Response Number 3
Name: SN
Date: August 8, 2005 at 07:12:12 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: Javascript weird problem

Images in Javascript with http:// l www.computing.net/answers/webdevel/images-in-javascript-with-http-l/534.html

Javascript download menu problems www.computing.net/answers/webdevel/javascript-download-menu-problems/1418.html

Internet Explorer problem www.computing.net/answers/webdevel/internet-explorer-problem/2431.html