Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 7th, 2004, 03:31 PM
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reading Array from DOM

My question is where in the IE DOM is the variable exposed? Put another way, I want to read the value of an element in the array but can't seem to find it in the DOM.

In the following code I create an instance of IE within VFP, load the document with a simple page (also shown below "test.htm") that contains some script code. The script includes an array. (I assume the same answer will work in any language - Java, C#, VB...).

oIE=CREATEOBJECT('internetexplorer.application')
oIE.Navigate='test.htm'
oIE.Visible = .t.

* thie following does not work and the question is what does?
? oIE.document.aTest.1

**** test.htm

<html>
<head>
<script language="javaScript">
var aTest = new Array(2)
aTest[0]='test0'
aTest[1]='test1'
aTest[2]='test2'
</script>
</head>
<body>
hello world
<script>alert(aTest[1])</script>
</body>
</html>

Thanks in advance to anyone that has any clues! <g>


 
Old February 7th, 2004, 04:27 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Not sure what you want. To access array in this instance you need parentWindow.atest but your code seems wrong to start with. Assuming you are running a stand alone script:
Code:
var oIE = new ActiveXObject("InternetExplorer.Application");
oIE.navigate("test.htm");
while(oIE.readyState != 4)
{
  WScript.sleep(500);
}
oIE.visible = true;
WScript.echo(oIE.document.parentWindow.atest[1]);


--

Joe
 
Old February 9th, 2004, 02:06 PM
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks but the problem seems to be within Visual FoxPro not being able to read array collections.

I tried your "parentWindow" suggestion and it returned the same results and I was seeing in my original example. I get a message that reads "Command contains unrecognized phrase/keyword." This is some sort of internal VFP message. The intelisense shows the zero and one members but that is as close as it gets.

So thanks for your help. I'm going to pass this one on to MS and see if they can find the problem.

--Harvey






Similar Threads
Thread Thread Starter Forum Replies Last Post
Convering a String Array to an Integer array nkrust C# 9 November 17th, 2010 12:02 PM
Go from 2d Array to 1d array without defining type OneQuestion General .NET 1 January 10th, 2008 11:13 AM
reading data from multidimensional array shish1 Beginning PHP 4 April 1st, 2007 06:42 PM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM
Problem with reading array from ActiveX DLL acdsky Classic ASP Components 1 June 15th, 2004 02:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.