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.
<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.
<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.
var ceURL = 'http://yourdomain.com/path-to-your-install/';
Lastly, you will need to enter the domain product group in line 6.
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:
<IfModule mod_headers.c>
Header add Access-Control-Allow-Origin "https://www.yourdomain.com"
Header add Access-Control-Allow-Methods "POST"
</IfModule>
Updated on: 05/03/2024
Thank you!