By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,023 Members | 1,235 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,023 IT Pros & Developers. It's quick & easy.

Call javascript function from browser control?

P: n/a
I'm using the Browser control to display html that my application generates.
Some times i want a javascript to run when the html gets displayed in the
browser control, and sometimes i dont.

Is there a way to invoke a javascript function from the browser control? or
maybe inject some javascript vis the control's reference to the Document
object? I think i can do it with the Window object, but I have seem to
figout out how to get to the Window object from the browser control or the
Document object.

Any ideas?

Dec 28 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Think this through. What triggers whether or not JavaScript should run?

If user action, does it cause a server trip or not?
If so, embed the code when you roundtrip the page.
If not, you may want to try to whack at it in the manner you are attempting.

What triggers the action? Time? User Interaction?
Even if you do not have a server trip, a planned user action can be embedded
when the page is delivered to the user.

When you are dealing with a web application, which is what you are dealing
with in the control, try to stick to the model provided rather than whacking
at the code from the container (actual browser or browser control).

The biggest question is this: what are you trying to accomplish (the
problem, not the technology to solve the problem) and why? Answering those
questions will give you a better answer as to what you should do. If you try
to solve technology first, you will likely end up with a wrong answer.

If you are trying to change pages, that can be accomplished by the browser
control itself or in the page. If the page is being clicked, you should
control it in the web app. If you are trying to change the way the contained
application works, you are better to envision the proposed solution and embed
the JavaScript on a server trip that can handle a specific click.

Good luck!

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"john conwell" wrote:
I'm using the Browser control to display html that my application generates.
Some times i want a javascript to run when the html gets displayed in the
browser control, and sometimes i dont.

Is there a way to invoke a javascript function from the browser control? or
maybe inject some javascript vis the control's reference to the Document
object? I think i can do it with the Window object, but I have seem to
figout out how to get to the Window object from the browser control or the
Document object.

Any ideas?

Dec 28 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.