> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://docs.clientexec.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Adding A Domain Search To An External Page/Site

If you want to add a domain availability search to your website, add the following code on your website, where you want the search to appear. 

```javascript
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<input id="domainname" type="text" name="domainname" value='yournewsite.com' />
<input id="submit-button" type="submit" value="Search Domain">
<script type="text/javascript">
  var ceURL = 'https://www.changeme.com/clientexec/';
  var groupId = 2;
  $('#submit-button').click(function(e) {
  e.preventDefault();
  var fullname = $('#domainname').val();
  if ( fullname.indexOf(".") == -1 ) {
  $('#domainname').addClass('domain_fail');
  $('#domainname').val(fullname+' - not a valid domain name');
  } else {
  name = fullname.substr(0, fullname.indexOf('.'));
  tld = fullname.substr(fullname.indexOf('.')+1);
  $.post(ceURL + 'index.php?fuse=clients&action=checkdomain',
  {
  name: name,
  tld: tld,
  group: groupId
  }, function(response) {
  console.log(response);
  if ( response.error ) {
  alert(response.message);
  } else {
  var domainStatus = response.search_results.status;
  if ( domainStatus == '0' ) {
  window.location = ceURL + 'order.php?step=1&productGroup=' + groupId + '&domainName=' + name + '&tld=' + tld;
  } else if ( domainStatus == '1' ) {
  window.location = ceURL + 'order.php?step=1&productGroup=' + groupId + '&domainName=' + name + '&tld=' + tld;
  } else {
  alert('there was an error, please try again later');
  }
  }
  }, 'json');
  }
  return false;
  });
</script>
```

If you want to change the default text displayed in the search box, modify this entry on the 2nd line.

```html
<input id="domainname" type="text" name="domainname" value='yournewsite.com' />
```

You will need to input your domain and path to CE install on line 5.

```html
var ceURL = 'http://yourdomain.com/path-to-your-install/';
```

Lastly, you will need to enter the domain product group in line 6.

```html
var groupId = 2;
```

### Using the domain search with a subdomain 

If your CE installation is located on a subdomain, and you want to use CE for a domain search on your website, you will need to create a .htaccess rule with the following information:

```html
<IfModule mod_headers.c>
      Header add Access-Control-Allow-Origin "https://www.yourdomain.com"
      Header add Access-Control-Allow-Methods "POST"
  </IfModule>
```