Through the URL
Parameters can be passed through the URL. These parameters are placed after the question-mark in the URL. Parameters are separated by a &-sign.
Example:
http://www.uwwebsites.nl/product/bestellen?cb_email=frank@cobrowser.net&cb_firstname=Frank&cb_l[]=Medewerker&cb_l[]=Cobrowser
The following parameters are recognised by CoBrowser.net:
- cb_lastname, cb_firstname, cb_company, cb_webaddress, cb_email, cb_phone, cb_cellphone, cb_city and cb_country
- To add labels use cb_l[] (see example). You can add more labels in one URL.
- To remove labels use cb_rl[]. You can remove more labels in one URL.
Using Javascript
Labels and fields can also be set and unset by using Javascript-calls. The following Javascript-functions are available:
- window.Cobrowser._setField(name, value [, callback = optional]) : for filling the fields of cb_lasttname, cb_firstname, cb_company, cb_webaddress, cb_email, cb_phone, cb_cellphone, cb_city and cb_country
- window.Cobrowser._addLabel(name [, callback = optional]) : for adding a label
- window.Cobrowser._removeLabel(name [, callback = optional]) : for removing a label
- window.Cobrowser._addNote(note [, callback = optional]) : for adding a note
The function window.cbReady can be implemented as onReady callback of the CoBrowser.net applciation. This way the Javascript functions are called when the application is fully loaded and active.
<script type="text/javascript">
window.cbReady = function()
{
// wait for cobrowser to be ready and initialized, than start this function
var _cb = window.Cobrowser; //shortcut to cobrowser api
var _cq = window.cbQuery; //shortcut to jquery api
// add firstname and lastname
_cb._setField('cb_firstname', 'John');
_cb._setField('cb_lastname', 'Smith');
// set field with callback
_cb._setField('cb_email', 'john@example.com', function(response) {
//console.log(response);
});
// add label without callback (only existing labels will be added)
_cb._addLabel('test');
// remove label without callback
_cb._removeLabel('test');
// set field when user types email address, replace field_email with the id of the input element
_cq('#field_loan').bind('blur.autofill', function() {
_cb._addLabel('test');
});
};
</script>
Note:
- Values are overwritten with every call.
- Adding of labels only works for existing labels (security measure).
Comments
0 comments
Please sign in to leave a comment.