🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
14 messages
14 total messages Started by bcb Thu, 24 Feb 2005 04:05
get text from javascript?
#1354
Author: bcb
Date: Thu, 24 Feb 2005 04:05
10 lines
1220 bytes
Hello :)

My program downloads a php file from a site which contains an embedded
javascript function. The script displays a countdown timer on the web page.
Is it possible to get the text of the count down script which is currently
displayed on the site. I'm not certain if this is possible but you never
know.

Thanks very much for taking your time to read this and for any suggestions
or info.
Re: get text from javascript?
#1355
Author: Hans Galema
Date: Thu, 24 Feb 2005 08:44
13 lines
1286 bytes
bcb wrote:

> My program downloads a php file from a site which contains an embedded
> javascript function. The script displays a countdown timer on the web page.
> Is it possible to get the text of the count down script which is currently
> displayed on the site.

Yes.

Is the script embedded in the resulting html source or
is it in a .js file and included ?

Hans.
Re: get text from javascript?
#1370
Author: bcb
Date: Thu, 24 Feb 2005 18:52
24 lines
1663 bytes
Hi Hans.

Thanks for replying.

The script is embeddeded in the resulting php file.


"Hans Galema" <notused@notused.nl> wrote in message
news:421d944d@newsgroups.borland.com...
> bcb wrote:
>
> > My program downloads a php file from a site which contains an embedded
> > javascript function. The script displays a countdown timer on the web
page.
> > Is it possible to get the text of the count down script which is
currently
> > displayed on the site.
>
> Yes.
>
> Is the script embedded in the resulting html source or
> is it in a .js file and included ?
>
> Hans.
Re: get text from javascript?
#1369
Author: bcb
Date: Thu, 24 Feb 2005 18:54
9 lines
1273 bytes
The file resulting has a php extention but of html format.

"bcb" <noemail@sorry.com> wrote in message
news:421e225a$1@newsgroups.borland.com...
> Hi Hans.
>
> Thanks for replying.
>
> The script is embeddeded in the resulting php file.
Re: get text from javascript?
#1375
Author: Hans Galema
Date: Thu, 24 Feb 2005 22:34
10 lines
1278 bytes
bcb wrote:

> The script is embeddeded in the resulting php file.

Get the hrmldata with a HTTP component like TIdHTTP or
TNMHTTP. You could even use TCppWebBrowser.

Then parse the data. Just look for <script> and so on.

Hans.
Re: get text from javascript?
#1376
Author: bcb
Date: Fri, 25 Feb 2005 00:02
17 lines
1489 bytes
Thanks Hans. I already know how to download the file but embedded in the
html file is the actual JavaScript code, not exactly what is displayed to
the public on the website itself.


"Hans Galema" <notused@notused.nl> wrote in message
news:421e56d9$1@newsgroups.borland.com...
> bcb wrote:
>
> > The script is embeddeded in the resulting php file.
>
> Get the hrmldata with a HTTP component like TIdHTTP or
> TNMHTTP. You could even use TCppWebBrowser.
>
> Then parse the data. Just look for <script> and so on.
>
> Hans.
Re: get text from javascript?
#1377
Author: Remy Lebeau (TeamB)
Date: Fri, 25 Feb 2005 00:08
13 lines
1415 bytes
"bcb" <noemail@sorry.com> wrote in message
news:421e6b0c$1@newsgroups.borland.com...

> Thanks Hans. I already know how to download the file but
> embedded in the html file is the actual JavaScript code, not
> exactly what is displayed to the public on the website itself.

Sounds like you will probably have to actually execute the script in order
to know what output it produces.


Gambit
Re: get text from javascript?
#1379
Author: bcb
Date: Fri, 25 Feb 2005 00:09
24 lines
1626 bytes
Part of the script looks something like

if (document.all)
document.all.countDownText.innerText = secsToMins(countDownTime);

else if (document.getElementById)
document.getElementById("countDownText").innerHTML =
secsToMins(countDownTime);

would it be possible to get the value of  the CountDownTime variable?


"Hans Galema" <notused@notused.nl> wrote in message
news:421e56d9$1@newsgroups.borland.com...
> bcb wrote:
>
> > The script is embeddeded in the resulting php file.
>
> Get the hrmldata with a HTTP component like TIdHTTP or
> TNMHTTP. You could even use TCppWebBrowser.
>
> Then parse the data. Just look for <script> and so on.
>
> Hans.
Re: get text from javascript?
#1378
Author: Remy Lebeau (TeamB)
Date: Fri, 25 Feb 2005 00:32
10 lines
1232 bytes
"bcb" <noemail@sorry.com> wrote in message
news:421e6cba$1@newsgroups.borland.com...

> would it be possible to get the value of  the CountDownTime variable?

You did not show where it is declared or assigned.


Gambit
Re: get text from javascript?
#1380
Author: bcb
Date: Fri, 25 Feb 2005 02:00
54 lines
2389 bytes
Hi Remy :)

Here is the piece of the html source:

the script:

<script language="JavaScript" type="Text/JavaScript">
<!--
var countDownInterval = 46;
var countDownTime = countDownInterval + 1;

if (document.all||document.getElementById)
countDown();
else
window.onload = countDown;

function countDown() {
countDownTime--;
if (countDownTime == 0) {
countDownTime = countDownInterval;
window.location.reload();
return;
}

else if (countDownTime < 5)
countDownTime = countDownTime + 00000;
if (document.all)
document.all.countDownText.innerText = secsToMins(countDownTime);
else if (document.getElementById)
document.getElementById("countDownText").innerHTML =
secsToMins(countDownTime);
counter = setTimeout("countDown()", 1000);
}

function secsToMins(theValue) {
var theMin = Math.floor(theValue / 60);
var theSec = (theValue % 60);
if (theSec < 10)
theSec = "0" + theSec;
return(theMin + ":" + theSec);
}
// -->
</script>

the part of the html source involved with actually displaying the info looks
something like,

<tr>
<td class="td01" height="63" colspan="3" valign="middle" align="center">
<br>
Count down display (<span id="countDownText"></span>)<br>
<br>
</td>
</tr>
Re: get text from javascript?
#1381
Author: Remy Lebeau (TeamB)
Date: Fri, 25 Feb 2005 02:56
11 lines
1519 bytes
"bcb" <noemail@sorry.com> wrote in message
news:421e86d1$1@newsgroups.borland.com...

> Here is the piece of the html source:

That script dynamically changes the page's text 47 times.  Do you want to
retreive all 47 text messages that get displayed to the user?


Gambit
Re: get text from javascript?
#1382
Author: bcb
Date: Fri, 25 Feb 2005 04:02
7 lines
1426 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
> That script dynamically changes the page's text 47 times.  Do you want to
> retreive all 47 text messages that get displayed to the user?

I just need to get the first instance, then I can continue the countdown
timer using a TTimer.
Re: get text from javascript?
#1383
Author: Remy Lebeau (TeamB)
Date: Fri, 25 Feb 2005 04:10
12 lines
1550 bytes
"bcb" <noemail@sorry.com> wrote in message
news:421ea351$1@newsgroups.borland.com...

> I just need to get the first instance, then I can continue
> the countdown timer using a TTimer.

Just load the script/html into a TStringList and then locate and parse out
the lines that declare the countDownInterval and countDownTime variables.


Gambit
Re: get text from javascript?
#1284
Author: bcb
Date: Fri, 25 Feb 2005 05:36
29 lines
2245 bytes
Remy and Hans, thanks for taking your time to help.

Working with a TStringList is a good idea.  I now see exactly  how the site
code works. Got lucky the first try when trying to match the site's text
with html code, everything matched but then lead myself astray.  I was using
IE's view source menu command without actually refreshing the page before
each view of the source, the countDownInterval changes with every refresh,
duh! ;) . My knowledge of html is very minute, took a while to understand
the whole page's code.

Thanks again for your time :)


"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:421ea65a@newsgroups.borland.com...
>
> "bcb" <noemail@sorry.com> wrote in message
> news:421ea351$1@newsgroups.borland.com...
>
> > I just need to get the first instance, then I can continue
> > the countdown timer using a TTimer.
>
> Just load the script/html into a TStringList and then locate and parse out
> the lines that declare the countDownInterval and countDownTime variables.
>
>
> Gambit
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads