Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Newbie Alert

2 views
Skip to first unread message

Mel Smith

unread,
Aug 12, 2008, 11:12:51 PM8/12/08
to
Hi:

I am a programmer (but in a language that is compiled into C code --
then onto .obj and and then an executable -- xHarbour)

I already am able to (programmatically) visit websites, and read (using
IE and innerHTML) pages, then parse the textual contents of the page to
glean the info I need. The websites I am visiting use Javascript 1.1

Now, I need to emulate/enter a 'UserName' and 'Password', then produce a
'Click' on the 'Submit' button all within my program.

btw, I have ordered Javascript The Definitive Guide thru Amazon, and
will get delivery within 5 days. In the meantime, do you have any hints on
producing a 'click' on the Submit button.

another btw, I have looked thru the Javascript Guide and haven't got
much further.

Anyway, it turns out that Javascript is very close in syntax to my
xHarbour opensource language (see www.xharbour.org) and I'm anxious to
learn!!

Thanks !

--
Mel Smith


Erwin Moller

unread,
Aug 13, 2008, 6:38:15 AM8/13/08
to

Mel Smith schreef:

Hi,

Try this:
<script type="text/javascript">
document.forms["formnamehere"].submit();
</script>

for a form named "formnamehere", so:
<form action="whatever" name="formnamehere">
<input etc.>
</form>

Be sure the page is loaded completely before submitting it.
So NOT in the order I showed you above. ;-)
Have a look at the onload handler.


Regards,
Erwin Moller

--
============================
Erwin Moller
Now dropping all postings from googlegroups.
Why? http://improve-usenet.org/
============================

Henry

unread,
Aug 13, 2008, 6:52:32 AM8/13/08
to
On Aug 13, 4:12 am, Mel Smith wrote:
<snip>

> I already am able to (programmatically) visit websites,
> and read (using IE and innerHTML) pages, then parse the
> textual contents of the page to glean the info I need.

So that would be instantiating and externally driving an IE web
browser COM component?

> The websites I am visiting use Javascript 1.1

That is improbable. HTML LANGUAGE attributes in SCRIPT elements have
very little use or meaning nowadays.

> Now, I need to emulate/enter a 'UserName' and 'Password',
> then produce a 'Click' on the 'Submit' button all within my
> program.

<snip>


> In the meantime, do you have any hints on producing a 'click'
> on the Submit button.

IE provides a - click - method on its submit button elements. Calling
that will have the same (theoretically form submitting) consequences
as a user clicking the button with some pointing device, except that -
click -, - focus - and - blur - events will not necessarily occur on
that element. The - submit - event of the containing form will be
triggered.

Calling the click method is going to be something like:-

document.forms['formNameOrIndex'].elements['buttonNameOrIndex'].click();

- where - document - may need to be substituted with whatever form of
property accessor gives you a referece to the document in your IE web
browser component.

See also:-

<URL: http://jibbering.com/faq/faq_notes/form_access.html >

Mel Smith

unread,
Aug 13, 2008, 10:31:47 AM8/13/08
to
Erwin & Henry:

Thank you both for your guidance !

I'll puzzle over your info today (while golfing), and respond tomorrow.

(btw, it shows javascript 1.1 in the source code of all the pages
provided . Hmmmm ..)

(another btw. Yes, I instantiate IE and use

Thanks again !

-Mel Smith

------- a small part of my proggie is below ----
// a small part of my program is below:

TRY
oIE := GetActiveObject( "InternetExplorer.Application" )
CATCH
TRY
oIE := CreateObject( "InternetExplorer.Application" )
CATCH
Alert( "ERROR ! IExplorer not available. [" + Ole2TxtError()+
"]" )
RETURN
END
END

oIE:Visible := .F.


cWebSite := "http://www.xxxx.org/xxxxxx/zzzzzzzz.aspx?ID="+someid

oIE:Navigate(cWebSite)

while oIE:busy

SecondsSleep(1.00)

ENDDO

// Knowing the username and password (my own) I wish to 'submit'
// the page after entering these input values, then 'click' on
// the submit button

// now carry on parsing and processing
// then 'Loop' and do other stuff

Henry

unread,
Aug 13, 2008, 11:58:01 AM8/13/08
to
On Aug 13, 3:31 pm, Mel Smith wrote:
<snip>

> TRY
> oIE := GetActiveObject( "InternetExplorer.Application" )
> CATCH
> TRY
> oIE := CreateObject( "InternetExplorer.Application" )
> CATCH
> Alert( "ERROR ! IExplorer not available. [" +
> Ole2TxtError()+ "]" )
> RETURN
> END
> END
>
> oIE:Visible := .F.
>
> cWebSite := "http://www.xxxx.org/xxxxxx/zzzzzzzz.aspx?ID="+someid
>
> oIE:Navigate(cWebSite)
>
> while oIE:busy
>
> SecondsSleep(1.00)
>
> ENDDO
<snip>

Given that, a recognisable equivalent of your intention using Windows
Scripting Host and written in JScript would be:-

var ieInstance, ieDocument, ieGlobal;
var someid = 'XXXXX';
ieInstance = new ActiveXObject("internetexplorer.application");
if(ieInstance){
ieInstance.resizable = true;
ieInstance.width = 500;
ieInstance.height = 400;
ieInstance.navigate(
"http://www.xxxx.org/xxxxxx/zzzzzzzz.aspx?ID="+someid
);
ieInstance.visible = true;
while(ieInstance.readyState != 4){
WScript.Sleep(100);
}
ieDocument = ieInstance.document;
ieGlobal = ieDocument.parentWindow;

ieDocument.forms['FN'].elements['UN'].value = 'User Name';
ieDocument.forms['FN'].elements['PW'].value = 'password';


ieDocument.forms['FN'].elements['SB'].click();
//or
//ieDocument.forms['FN'].submit();
}

Substituting 'FN'. 'UN', 'PW', and 'SB' for the names of the FORM,
user name field, password field and submit button respectively.

Mel Smith

unread,
Aug 13, 2008, 6:35:31 PM8/13/08
to
Henry said:

Henry:

I'll give that a try tomorrow.

-Mel Smith


0 new messages