Copy and paste the following script.
<script language="ecmascript" type="text/ecmascript">
var contentTypeCollection;
function getSiteContentTypes() {
var clientContext = new SP.ClientContext.get_current();
if (clientContext != undefined && clientContext != null) {
var web = clientContext.get_web();
this.contentTypeCollection = web.get_contentTypes();
clientContext.load(this.contentTypeCollection);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
}
function onQuerySucceeded() {
var contentType = 'Site Content Types:\n '
var contentTypeEnumerator = this.contentTypeCollection.getEnumerator();
while (contentTypeEnumerator.moveNext()) {
var content = contentTypeEnumerator.get_current();
contentType += content.get_name() + '\n';
}
alert(contentType);
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}</script>
<input id="btnGetSiteContentTypes" onclick="getSiteContentTypes()" type="button"
value="Get Site Content Types" />