Source language: Translate to:

Getting a list of web browser elements

Questions and information about creating Internet aware NeoBook applications. Including PHP, HTML, FTP, HTTP, Email, etc.

Moderator: Neosoft Support

Getting a list of web browser elements

Postby andybrock » Sat Jun 05, 2010 10:19 am

Neobook has a getbrowserelement and setbrowserelement command which is great if you know the names of the elements. Is there any way to load a page and then get a list of all the elements on that web page which can be got or set by the get and set commands?

Andy
User avatar
andybrock
 
Posts: 181
Joined: Mon Apr 20, 2009 1:38 pm
Location: Somerset, UK

Postby Gaev » Sat Jun 05, 2010 3:58 pm

Andy:

The BrowserGetElement command needs the name of the element whose content you want copied to a [variable].

But elements do not need to be named in order to be rendered by a Browser ... as a result most elements in a typical HTML document are NOT named.

Elements in an HTML document have a hierarchial (parent-children) relationship ... and there are Javascript/DHTML commands to traverse this inverted-tree structure ... while you can ask NeoBook (via the BrowserExecScript command) to execute such commands, you need a good understanding of this structure and the Javascript/DHTML commands in order to do anything beneficial with it.
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby bunker » Sat Jun 05, 2010 10:30 pm

Hi I made a simple html example:

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form Test</title>
<script language="JavaScript">

function GetElements()
{
   for(i=0; i<document.test_form.elements.length; i++)
    {
      alert("Type: " + document.test_form.elements[i].type + " Name: " + document.test_form.elements[i].name);
    }
}   

</script>
</head>
<body>
<form name="test_form" id="test_form" action="#">

Name: <input type="text" name="name" id="txt_name">

Email: <input type="text" name="email" id="txt_email">

<input type="button" name="submit" value="Submit">

</form>
<a href="javascript:GetElements()">Get elements</a>
</body>
</html>


You can modify the javascript so that you return the items in a vector in NeoBook ...

Greetings
User avatar
bunker
 
Posts: 141
Joined: Sat Sep 29, 2007 4:00 pm

Postby andybrock » Sun Jun 06, 2010 12:51 am

Thank you, that's awesome.

Andy
User avatar
andybrock
 
Posts: 181
Joined: Mon Apr 20, 2009 1:38 pm
Location: Somerset, UK


Return to NeoBook and the Internet

Who is online

Users browsing this forum: No registered users and 0 guests