Flamingo.switchType()

The switchType() method is used to switch between desktop and mobile views of the current page.

Note

For all elements with the data-flamingo-switcher attribute Flamingo will automatically add listener on click event and run the Flamingo.switchType() method with parameter specified as an attribute value.

Syntax

Flamingo.switchType(viewType)

Parameters

Parameter Type Description
viewType String ’pc’ or ‘mobile’ strings that represent desktop and mobile views accordingly.

Return Value

No return value.

Example 1

You can use the following code in template to add a link on mobile page that will open original desktop page:

<a href="javascript:Flamingo.switchType('pc')">Desktop View</a>

If user clicks this link, they will be switched to the original desktop presentation of the page.

Example 2

You can use the following code in template to add a link with the data-flamingo-switcher attribute on mobile page:

<a href="javascript:void(0)" data-flamingo-switcher="pc">Desktop View</a>

Flamingo will automatically detect the data-flamingo-switcher attribute. If user clicks this link, they will be switched to the original desktop page presentation.

Example 3

You can use the following code in original desktop page to add a link with the data-flamingo-switcher attribute so user may switch back to the mobile version:

<a href="http://wap.mysite.com" data-flamingo-switcher="mobile">Back to Mobile View</a>

Flamingo will automatically detect the data-flamingo-switcher attribute. If user clicks this link, they will be switched back to the mobile view.

See Also