473,241 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

Accessing a local variable (timer ID)

Joe
Hi,

I am trying to alter the refresh rate of an online webpage in a webbrowser
control using MFC. However the Timer ID is stored in a local variable and I
don't know how to access it. Is there a technique in Javascript that I might
be able to use/adapt?

I have a timer set within a prototype thus:

;HControl.prototype.setFLTimeout = function() {
var oFLTimeout = setTimeout("hCtrl.mkView.reloadFL();", iFLTimeout);
}

But the timer Id oFLTimeout is local so, once the page is loaded how can I
access and stop the timer to prevent the page refreshing (or perhaps "reset"
it to my own bespoke rate)?
The only way I know how is using clearTimeout(), however this method
requires the timer ID.

Can I "list" all the timers somehow?

I really am stumped and would like some advise on how I can progress.

Thanks

Jul 23 '05 #1
18 2132
Joe wrote on 13 sep 2004 in comp.lang.javascript:
I am trying to alter the refresh rate of an online webpage in a
webbrowser control using MFC. However the Timer ID is stored in a
local variable and I don't know how to access it. Is there a technique
in Javascript that I might be able to use/adapt?

I have a timer set within a prototype thus:

;HControl.prototype.setFLTimeout = function() {
var oFLTimeout = setTimeout("hCtrl.mkView.reloadFL();", iFLTimeout);


So use a global variable.

You are the boss of the code, aren't you?

===

var oFLTimeout;

HControl.prototype.setFLTimeout = function() {
oFLTimeout = setTimeout("hCtrl.mkView.reloadFL();", iFLTimeout);

===

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 23 '05 #2
Joe
> So use a global variable.

You are the boss of the code, aren't you?


No, I'm not!

Perhaps I wasn't clear enough, I said "online webpage" in other words I'm
downloading the page and its scripts and I want to inhibit/change the page
refresh timer.

Thanks
Jul 23 '05 #3
Joe wrote on 13 sep 2004 in comp.lang.javascript:
So use a global variable.

You are the boss of the code, aren't you?


No, I'm not!

Perhaps I wasn't clear enough, I said "online webpage" in other words
I'm downloading the page and its scripts and I want to inhibit/change
the page refresh timer.


Indeed you were not very clear.

So open the page,
go to view source,
change the code and save the local file,
then execute this local file,
if necessary after adding:
<base href="http://the original url here"> in the <head> section.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 23 '05 #4
Lee
Joe said:

Hi,

I am trying to alter the refresh rate of an online webpage in a webbrowser
control using MFC. However the Timer ID is stored in a local variable and I
don't know how to access it. Is there a technique in Javascript that I might
be able to use/adapt?


Stop trying to cheat on whatever timed test it is
that you're trying to hack.

Jul 23 '05 #5
Joe

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn******************@194.109.133.29...
Joe wrote on 13 sep 2004 in comp.lang.javascript:
So use a global variable.

You are the boss of the code, aren't you?


No, I'm not!

Perhaps I wasn't clear enough, I said "online webpage" in other words
I'm downloading the page and its scripts and I want to inhibit/change
the page refresh timer.


Indeed you were not very clear.

So open the page,
go to view source,
change the code and save the local file,
then execute this local file,
if necessary after adding:
<base href="http://the original url here"> in the <head> section.


Well I'm still not being very clear:)

I want to download the web page into my browser control.
I want to then execute a "function" within my MFC program through the
script interface which will allow me to "automatically" adjust the refresh
rate by altering the script function dynamically.

If the timerID is a global variable I can do it.

However as it is a local variable I can't.

"Manually" changing the page scripts isn't an option.


Jul 23 '05 #6
Joe

"Lee" <RE**************@cox.net> wrote in message
news:ci*********@drn.newsguy.com...
Joe said:

Hi,

I am trying to alter the refresh rate of an online webpage in a webbrowsercontrol using MFC. However the Timer ID is stored in a local variable and Idon't know how to access it. Is there a technique in Javascript that I mightbe able to use/adapt?


Stop trying to cheat on whatever timed test it is
that you're trying to hack.

Thanks Lee, very useful. Of course, I'm not "cheating" anything.

Have you any constructive comments to make which might actually help me out?
Jul 23 '05 #7
Joe wrote on 13 sep 2004 in comp.lang.javascript:
Well I'm still not being very clear:)

I want to download the web page into my browser control.
What is a "browser control"?
I want to then execute a "function" within my MFC program through the
script interface which will allow me to "automatically" adjust the
refresh rate by altering the script function dynamically.

If the timerID is a global variable I can do it.

However as it is a local variable I can't.

"Manually" changing the page scripts isn't an option.


Changing the page by script should be possible.

I suppose you want to do some data mining.

Like this?

function getUrl(url) {
var http = new ActiveXObject("microsoft.xmlhttp");
http.open("GET",url,false);
http.send();
return http.responseText;
}

When the content of the file is in a local variable as a string,
you can replace parts of that string with multiple regex replace.

t = getUrl('http://yourTargettedWEBsource.com/')

t = t.replace(/;HControl.prototype/,
'var oFLTimeout\n;HControl.prototype')
t = t.replace(/var oFLTimeout/,'oFLTimeout')
After that you can execute the string as if it were a http file.

[How? I have to think about that ;-) ]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 23 '05 #8
Lee
Joe said:


"Lee" <RE**************@cox.net> wrote in message
news:ci*********@drn.newsguy.com...
Joe said:
>
>Hi,
>
>I am trying to alter the refresh rate of an online webpage in awebbrowser >control using MFC. However the Timer ID is stored in a local variable andI >don't know how to access it. Is there a technique in Javascript that Imight >be able to use/adapt?


Stop trying to cheat on whatever timed test it is
that you're trying to hack.

Thanks Lee, very useful. Of course, I'm not "cheating" anything.


You're welcome.

It's not your page. Somebody put a timer there for a
reason. You're trying to change it. That fits my
definition of cheating.

If it happens not to be a test, posting a solution (if
one existed) would allow others to cheat on such tests.

Jul 23 '05 #9
Joe

"Lee" <RE**************@cox.net> wrote in message
news:ci*********@drn.newsguy.com...
Joe said:


"Lee" <RE**************@cox.net> wrote in message
news:ci*********@drn.newsguy.com...
Joe said:
>
>Hi,
>
>I am trying to alter the refresh rate of an online webpage in awebbrowser
>control using MFC. However the Timer ID is stored in a local variable
andI
>don't know how to access it. Is there a technique in Javascript that I

might
>be able to use/adapt?

Stop trying to cheat on whatever timed test it is
that you're trying to hack.

Thanks Lee, very useful. Of course, I'm not "cheating" anything.


You're welcome.

It's not your page. Somebody put a timer there for a
reason. You're trying to change it. That fits my
definition of cheating.

If it happens not to be a test, posting a solution (if
one existed) would allow others to cheat on such tests.


So you're posting smart-arse comments from baseless assumptions when you
have no idea at all why I want to do what I'm asking.

That fits my definition of a ******* ******.

Have a nice day.


Jul 23 '05 #10
Joe

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Joe wrote on 13 sep 2004 in comp.lang.javascript:
Well I'm still not being very clear:)

I want to download the web page into my browser control.
What is a "browser control"?


Microsofts WebBrowser Control.
By downloading a page into that I can get "programatic" access to the
documents properties and objects, scripts etc and do some "bespoke"
operations on them (hopefully) such as altering the refresh rate. It also
allows you to execute javascript functions - "standard" such as
ClearTimeout() and user defined, but as the timerID is only defined locally
in the prototype settimer function I gave in my initial post I can't find
it.

Here's a refrence if you're interested:
http://msdn.microsoft.com/workshop/b...webbrowser.asp

Changing the page by script should be possible. I suppose you want to do some data mining.
Sort of.
But really I don't want unecessary refreshes clogging up bandwidth. Also any
solution might help me learn a nice way into the scripts.
Like this?

function getUrl(url) {
var http = new ActiveXObject("microsoft.xmlhttp");
http.open("GET",url,false);
http.send();
return http.responseText;
}
Maybe. With a webbrowser control its possible build that text as a function
and execute it as javascript. I'm sure you can in other languages but I'm
familiar with MFC (not an expert with the WBC or javascript though).

For instance I've managed to alter the timer rate and set up a new timer for
the page.
However, all this does is add a new timer in addition to the old so I end up
with both timers refreshing the page.

When the content of the file is in a local variable as a string,
you can replace parts of that string with multiple regex replace.

t = getUrl('http://yourTargettedWEBsource.com/')

t = t.replace(/;HControl.prototype/,
'var oFLTimeout\n;HControl.prototype')
t = t.replace(/var oFLTimeout/,'oFLTimeout')
After that you can execute the string as if it were a http file.

[How? I have to think about that ;-) ]


OK. Whatever ideas you may come up with I will obviously have to convert to
run in the WBC but thats my problem ;) - I just need a way forward.

Will the timer be prevented from running by changing the text, given that
the script may have been executed and the timer set up before the text is
altered?

I'm not sure how I can change any script after it is downloaded but before
it runs in a WBC. If its possible then I could just change the timer delay
variable to be whatever rate I want - although this would then be fixed for
the life of the WBC.

An ideal solution would be to delete the existing timer so that I can set up
a new timer to refresh at any rate I wish.

But any ideas appreciated.



Jul 23 '05 #11
"Joe" <no*@home.com> writes:
I want to download the web page into my browser control.
I want to then execute a "function" within my MFC program through the
script interface which will allow me to "automatically" adjust the refresh
rate by altering the script function dynamically.
I recommend changing the content of the page by intercepting the download
of the page, and then change the page before giving it to the control (if
intercepting is possible). You can then change the page to make the local
variable global, or something else.
If the timerID is a global variable I can do it. However as it is a local variable I can't.
Correct.
"Manually" changing the page scripts isn't an option.


Are you sure? It could be easier.

Also, getting the id of the timeout won't help you a lot anyway. All
you can do is cancel that one timeout. A better way would be to
replace the "setTimeout" with your own version, that calls the
original. Something like executing this script:

---
var oldSetTimeout = setTimeout;
var myOverrideTime;
var myLatestTimeout;
setTimeout = new function(arg,time) {
return (myLatestTimeout = oldSetTimeout(arg, myOverrideTime || time);
};
---

Good luck
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #12
Lee
Joe said:


"Lee" <RE**************@cox.net> wrote in message
news:ci*********@drn.newsguy.com...
Joe said:
>
>
>"Lee" <RE**************@cox.net> wrote in message
>news:ci*********@drn.newsguy.com...
>> Joe said:
>> >
>> >Hi,
>> >
>> >I am trying to alter the refresh rate of an online webpage in a
>webbrowser
>> >control using MFC. However the Timer ID is stored in a local variableand >I
>> >don't know how to access it. Is there a technique in Javascript that I
>might
>> >be able to use/adapt?
>>
>> Stop trying to cheat on whatever timed test it is
>> that you're trying to hack.
>
>
>Thanks Lee, very useful. Of course, I'm not "cheating" anything.


You're welcome.

It's not your page. Somebody put a timer there for a
reason. You're trying to change it. That fits my
definition of cheating.

If it happens not to be a test, posting a solution (if
one existed) would allow others to cheat on such tests.


So you're posting smart-arse comments from baseless assumptions when you
have no idea at all why I want to do what I'm asking.

That fits my definition of a ******* ******.


What part of my comments qualify as "smart-arse"?

No, you don't seem to read well. I do have a base for my
assumptions. You're trying to change the functionality of
somebody else's web page. That a pretty substantial base.
If you've got some justification, it's up to you to present
it, if you expect help.

I've also said that completely regardless of why you want to
do what you're asking for, it would be irresponsible to post
a solution (if one existed).

Jul 23 '05 #13
Joe

"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:mz**********@hotpop.com...
"Joe" <no*@home.com> writes:
I want to download the web page into my browser control.
I want to then execute a "function" within my MFC program through the
script interface which will allow me to "automatically" adjust the refresh rate by altering the script function dynamically.
I recommend changing the content of the page by intercepting the download
of the page, and then change the page before giving it to the control (if
intercepting is possible). You can then change the page to make the local
variable global, or something else.


Hello Lasse.

I've been investigating this for some time but haven't found out how to do
it through a WebBrowser Control - of course doesn't mean it can't easily be
done ;)

If the timerID is a global variable I can do it.

However as it is a local variable I can't.


Correct.
"Manually" changing the page scripts isn't an option.


Are you sure? It could be easier.


Well, depends on what one means by "manually". I want to run the program
automatically without having to be present.

Also, getting the id of the timeout won't help you a lot anyway. All
you can do is cancel that one timeout. A better way would be to
replace the "setTimeout" with your own version, that calls the
original. Something like executing this script:

---
var oldSetTimeout = setTimeout;
var myOverrideTime;
var myLatestTimeout;
setTimeout = new function(arg,time) {
return (myLatestTimeout = oldSetTimeout(arg, myOverrideTime || time);
};


Again, this is dependent on me being able to change the scripts before
execution which I'm trying to work out how to do.

Thanks


Jul 23 '05 #14
Joe

"Lee" <RE**************@cox.net> wrote in message
news:ci*********@drn.newsguy.com...
Joe said:


"Lee" <RE**************@cox.net> wrote in message
news:ci*********@drn.newsguy.com...
Joe said:
>
>
>"Lee" <RE**************@cox.net> wrote in message
>news:ci*********@drn.newsguy.com...
>> Joe said:
>> >
>> >Hi,
>> >
>> >I am trying to alter the refresh rate of an online webpage in a
>webbrowser
>> >control using MFC. However the Timer ID is stored in a local variable
and
>I
>> >don't know how to access it. Is there a technique in Javascript

that I >might
>> >be able to use/adapt?
>>
>> Stop trying to cheat on whatever timed test it is
>> that you're trying to hack.
>
>
>Thanks Lee, very useful. Of course, I'm not "cheating" anything.

You're welcome.

It's not your page. Somebody put a timer there for a
reason. You're trying to change it. That fits my
definition of cheating.

If it happens not to be a test, posting a solution (if
one existed) would allow others to cheat on such tests.


So you're posting smart-arse comments from baseless assumptions when you
have no idea at all why I want to do what I'm asking.

That fits my definition of a ******* ******.


What part of my comments qualify as "smart-arse"?

No, you don't seem to read well. I do have a base for my
assumptions. You're trying to change the functionality of
somebody else's web page. That a pretty substantial base.
If you've got some justification, it's up to you to present
it, if you expect help.

I've also said that completely regardless of why you want to
do what you're asking for, it would be irresponsible to post
a solution (if one existed).


Bye
Jul 23 '05 #15
"Joe" <no*@home.com> writes:
Again, this is dependent on me being able to change the scripts before
execution which I'm trying to work out how to do.


Ok. I don't have any experience with the MSHTML component, so I'll just
make some random guesses :)

Could you put the component into edit mode before loading the page?
Then you could use the WYSIWYG editing mode to insert or change content
before removing edit mode again. I don't know if that would prevent
scripts from running, or if it is possible to select edit mode before
loading the page.

Could you add a C++ event handler for the window's onload event?
(<URL:http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/prog_browser_node_entry.asp>
says the event "Fires immediately after the browser loads the object.". That
might be before the page's onload script, and it would be soon enough
to change the functionality of setTimeout).

Intercepting the page load might be possible using
<URL:http://msdn.microsoft.com/workshop/browser/ext/overview/downloadmgr.asp>

Good luck.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #16
Joe wrote on 13 sep 2004 in comp.lang.javascript:
Will the timer be prevented from running by changing the text, given that
the script may have been executed and the timer set up before the text is
altered?

No the script will not execut ig you xmlhttp-get it to a string.
Microsofts WebBrowser Control.


Sorry, I do not think we are talking on the same level.
This is not part of my javascript knowledge.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 23 '05 #17
Joe

"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:fz**********@hotpop.com...
"Joe" <no*@home.com> writes:
Again, this is dependent on me being able to change the scripts before
execution which I'm trying to work out how to do.
Ok. I don't have any experience with the MSHTML component, so I'll just
make some random guesses :)

Could you put the component into edit mode before loading the page?
Then you could use the WYSIWYG editing mode to insert or change content
before removing edit mode again. I don't know if that would prevent
scripts from running, or if it is possible to select edit mode before
loading the page.

Could you add a C++ event handler for the window's onload event?

(<URL:http://msdn.microsoft.com/library/de...hop/browser/pr
og_browser_node_entry.asp> says the event "Fires immediately after the browser loads the object.". That might be before the page's onload script, and it would be soon enough
to change the functionality of setTimeout).

Intercepting the page load might be possible using
<URL:http://msdn.microsoft.com/workshop/b...ownloadmgr.asp


Thanks for the pointers, though I'm not sure its as "simple" as that. Anyway
I've had enough for today ;)
Jul 23 '05 #18
"Joe" <no*@home.com> wrote in message news:<41***********************@news-text.dial.pipex.com>...
Hi,

I am trying to alter the refresh rate of an online webpage in a webbrowser
control using MFC. However the Timer ID is stored in a local variable and I
don't know how to access it. Is there a technique in Javascript that I might
be able to use/adapt?


Functions are variables in Javascript, so replace the function with
your own by a one liner on the command line.
Let's say you have the following function.
color.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Popup</title>
<SCRIPT type="text/javascript">
var colors = 0;
var colorList = ["red","yellow","blue"];

function changeColor()
{

colors = colors % colorList.length;

document.getElementById("colorit").style.color = colorList[colors];
colors++
setTimeout("changeColor()",1500);
}

</script>
</head>
<body onload="changeColor();">
<p id="colorit">Change the color of this text.</p>
</body>
</html>

Copy the following one line into broswer command line and press enter.

( I have included two versions of the one line. The first the real one
line and the second the list of statements you will have to make into
one line. )

There may be alimit on the size of the one line file. Maybe 2k in IE.

You should see the colors displayed change. I did with Netscape 7.2
and IE 5.2 on MacOS 10.2.6.


javascript: alert("injection.."); function changeColor() { var
colorList = ["black","pink","green"]; colors = colors %
colorList.length; document.getElementById("colorit").style.color =
colorList[colors]; colors++; setTimeout("changeColor()",500); }

javascript: alert("injection..");
function changeColor() { var colorList = ["black","pink","green"];
colors = colors % colorList.length;
document.getElementById("colorit").style.color = colorList[colors];
colors++; setTimeout("changeColor()",500); }
Robert
Jul 23 '05 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Erik Andersson | last post by:
Hi! <? class Foo { function getMessage() { return "foo"; } } class Bar { function getFoo() {
2
by: |-|erc | last post by:
OK, here's the start of the index file I'm working on and its used for every page like so index.php?action=register index.php?action=logout etc. <?php define ('IN_SITE', 1 ); define...
44
by: Mohanasundaram | last post by:
int i = 10; int main() { int i = 20; return 0; } Hi All, I want to access the global variable i inside the main. Is there
9
by: Bob Day | last post by:
VS 2003, vb.net , sql msde... I have an application with multiple threads running. Its a telephony application where each thread represents a telephone line. For code that would be the same...
2
by: Vincent | last post by:
I have been trying to find some API routines that will allow me to determine the name of the computer that is accessing a file on a server. I have found the NetFileEnum call (returns the names of...
9
by: Shilpa | last post by:
Hi, I just wanted to know whether we can access global variable within a local block , where both variables are having same name. For ex: int temp=5 ; { int temp=10;
0
by: Kabo | last post by:
Hi there, I'm currently working on a C# application that deals with dynamically created TabPages based (each TabPage represents a file that has been opened). On each TabPage there is a...
1
by: jobbs64 | last post by:
I'm working on a game called carpet fishing...long story...anyways I am having trouble working with the fish that I've created. I need to be able to access their Fish Class method move() so I can...
4
Dheeraj Joshi
by: Dheeraj Joshi | last post by:
Hi, I was wondering is there any technique available, so we can access the global variable inside a function if we have a local variable inside the function with the same name as global variable. ...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.