Search code examples
javascriptnavigationwebbrowser-controlinvoke

How to click a Javascript button that doesn't exist


I am trying to use WebBrowser control to click a button that doesn't have any anchor text or anything.

I looked at the source and saw this.

var _tm7 = new TabMenu('TempoTabMenuControl', 'TempoTabMenuControlRow',['Add Edit'], 0);

_tm7.Add(new TabMenuItem('View Menu', '/Edit/NewUI.html?tstudio=45', 'main'), true);

_tm7.Add(new TabMenuItem('Property List', '/Edit/Scripts/PrpList.asp', 'display'), false);

_tm7.Add(new TabMenuItem('New Listing', '/Edit/Scripts/NewList.asp', 'display'), false);

I guess its script to populate the fields of the dropdown menu. I want to get to /Edit/Scripts/NewList.asp but I have to do it with the JavaScript because the NewList.asp is only configured to work from within a frame with the main page as the parent.

The JavaScript file they use is here:

http://www.dailynewstube.com/Tabs.js

Is there some way to activate some kind of evil javascript method or something from the WebBrowser control?

JavaScript Gurus Please HelP!!


Solution

  • Most Web browsers have some sort of console that can be used to execute arbitrary JavaScript. Most also support an arguably faster method of executing JavaScript: placing javascript:[insert code here];void(0); in the URL bar.

    I'm guessing by "WebBrowser control", you mean a program with an embedded web browser, as opposed to a real web browser. The "javascript: in URL bar" method may still work, or if not, you could try browsing to the website in a real web browser and using its JavaScript console. Otherwise, you're pretty much out of luck unless you do something fancy involving a proxy.