Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi forum
I have a problem, I want to my webbrowser scroll down to a html element called "submit" anyone can help me?
Posted
Comments
thatraja 4-Aug-11 23:16pm    
Not clear, give us complete details
edumaite 5-Aug-11 0:05am    
I have a webbrowser and I want that when navigate to a site the browser scroll down to find a html element called "submit". example this code if for scroll down to a position:
browser.document.window.ScrollTo(0,100)
but I want to find a htmlelement like "submit" because this element has different positions in each site.
Sergey Alexandrovich Kryukov 5-Aug-11 1:19am    
Pretty good question (after clarification). Of course scrolling to a location by coordinate would not solve the problem.
--SA

1 solution

How do you know how to identify the element? There can be multiple text "Submit" on the page, etc. Is there any universal way to find it? As I understand, you want to navigate through some pages which are not yours.

I think the only reliable way to navigate to desired place is by URL. The element should either have an argument id or be marked with the anchor element a with the unique attribute name. For example, let's assume you have a Web page served under the URL http://www.myDomain.org/myPage.html with the button, optionally marked with a anchor.

HTML
<a name="scrollHere">
<button id="here" >Submit</button>


So, to navigate to the button based on anchor, use the URL

http://www.myDomain.org/myPage.html#scrollHere


If the anchor is not present but the button has the attribute name you can use it as well:

http://www.myDomain.org/myPage.html#here


—SA
 
Share this answer
 
v2
Comments
edumaite 5-Aug-11 1:46am    
Can you explain me? for example how you navigate (scroll down) to the button "add a solution" here in www.codeproject.com this is the html code:

id="ctl00_ctl00_MC_AMC_AddChild1

Thanks
Sergey Alexandrovich Kryukov 10-Aug-11 0:21am    
This is an unbalance fragment of HTML code. Assuming you need to show an element with this id, use
the same URL you already had, but add #ctl00_ctl00_MC_AMC_AddChild1:
http://you.domain.name/your-page.html#ctl00_ctl00_MC_AMC_AddChild1

I tested it before answering.

You can parse the HTML of already loaded page, find out element you want and id, and than change the URL to the one using id.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900