Flamingo.getDocument()

The getDocument() method returns DOM document object of the source website page.

Syntax

Flamingo.getDocument()

Parameters

None.

Return Value

Type Description
DOMDocument DOM document object of the source website page.

Example 1

The example below demonstrates how to add the TITLE element to your mobile website page.

Source HTML code available on your original desktop site page:

<html>
 <head>
   <title>Document Title</title>
 </head>
</html>

You need to add the following code to your template to display page title on your mobile website:

<!--{= Flamingo.getDocument().title }-->

The result will look like:

Document Title

Example 2

The example below demonstrates how to get HTML code of the element defined by id in the original page.

Source HTML code available on your original desktop site page:

<html>
 <body>
   <div id="test"><strong>Test element</strong></div>
 </body>
</html>

You need to add the following code to your template to display the HTML code defined by the test id in the original page:

<!--{= Flamingo.getDocument().getElementById('test').innerHTML }-->

The result will look like:

<strong>Test element</strong>

Example 3

The example below demonstrates how to get node value from the specified context node using XPath.

Source HTML code available on your original desktop site page:

<html>
 <body>
   <ul id="list1">
     <li>List 1 Item 1</li>
     <li>List 1 Item 2</li>
   </ul>
   <ul id="list2">
     <li>List 2 Item 1</li>
     <li>List 2 Item 2</li>
   </ul>
 </body>
</html>

You need to add the following code to your template to get node value from the specified context node using XPath:

<!--{= Flamingo.XPath.value('//li[1]', Flamingo.getDocument().getElementById('list2')) }-->

The result will look like:

List 2 Item 1

See also