473,386 Members | 1,610 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,386 software developers and data experts.

How to call Javascript on a Browser page from a .NET windows app?

Hi,

I am trying to call a javascript function on a page using the following code from a Windows app:
Dim objMSHTML2 As New mshtml.HTMLDocument
'I'm not sure what code should go in here
objMSHTML2.parentWindow.FunctionOnThePage("1")

The scenario is that the browser is already open on the page that contains the function being called ("FunctionOnThePage").

How do I tell objMSHTML2 to point to the browser instance that I want so that the function can be accessed?

Thanks in advance!

Regards,
CB
May 10 '07 #1
6 1322
TRScheel
638 Expert 512MB
Hi,

I am trying to call a javascript function on a page using the following code from a Windows app:
Dim objMSHTML2 As New mshtml.HTMLDocument
'I'm not sure what code should go in here
objMSHTML2.parentWindow.FunctionOnThePage("1")

The scenario is that the browser is already open on the page that contains the function being called ("FunctionOnThePage").

How do I tell objMSHTML2 to point to the browser instance that I want so that the function can be accessed?

Thanks in advance!

Regards,
CB
I am not sure I understand what you want... is this right:

There is a browser already up, and you want to access it and run the function called FunctionOnThePage() thats loaded on that page?
May 10 '07 #2
That is correct.

Thanks,
CB


I am not sure I understand what you want... is this right:

There is a browser already up, and you want to access it and run the function called FunctionOnThePage() thats loaded on that page?
May 11 '07 #3
kenobewan
4,871 Expert 4TB
Have you tried attributes.add("onclick", FunctionOnThePage())?
May 11 '07 #4
Hi again,

Just to clarify. The situation is that I am trying to fire off a JavaScript function on a page that is from a third party (i.e. I can't make any changes to it).

Let's say that the JavaScript function "FunctionOnThePage()" is something on www.yahoo.com. How do I call that from my Windows app?

Hope that's clearer.

Thanks again!
- CB
May 11 '07 #5
TRScheel
638 Expert 512MB
Hi again,

Just to clarify. The situation is that I am trying to fire off a JavaScript function on a page that is from a third party (i.e. I can't make any changes to it).

Let's say that the JavaScript function "FunctionOnThePage()" is something on www.yahoo.com. How do I call that from my Windows app?

Hope that's clearer.

Thanks again!
- CB
Well I know you can do javascript injection from the address bar... hence, you could do something like

Expand|Select|Wrap|Line Numbers
  1. javascript: alert("Hello");
in the address bar, and you would get a nice little pop up message. Now manipulating that programatically would be a bit tricky.

One thing I need to know, does this need to be ran on a running instance of say, IE7, or can this exist entirely in the realm of your program? The difference lies here:

If you are manipulating an running instance of IE7 it could be very difficult unless there is something available I am not aware of, BUT if its ok that this runs entirely inside your executable, you should be able to do this fairly easily.
May 15 '07 #6
Frinavale
9,735 Expert Mod 8TB
Hi again,

Just to clarify. The situation is that I am trying to fire off a JavaScript function on a page that is from a third party (i.e. I can't make any changes to it).

Let's say that the JavaScript function "FunctionOnThePage()" is something on www.yahoo.com. How do I call that from my Windows app?

Hope that's clearer.

Thanks again!
- CB
JavaScript functions are usually specific to the web page that they are embedded into. They are used to manipulate things on the Client Side (not Server Side).

I do not think it is possible to do what you are asking without some piece of malicious code. This is not a good idea, its unethical, and it will get you into trouble.

What exactly are you trying to capture from this JavaScript?
Why can't you write your own JavaScript that is specific for your program?
By writing your JavaScript, you can set a hidden variable on your page which can be accessed by your server side code...and this will keep you from trouble.

-Frinny
May 15 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.