Topic: Use jQuery to detect if your website is in SimpleCMS

SimpleCMS adds a meta tag to your web pages while viewing them in the system. This makes it easy for you to use jQuery to detect if your website is being viewed through the system so you can apply any special CSS or JavaScript rules. You should use the following code in your page to take advantage of this:

<script type="text/javascript">
$(document).ready(function()
{
    if ($('meta[name = "in-cms"]').size() > 0)
    {
        // your code here
    }
});
</script>

--
Short URL http://smplc.ms/detectcms

Re: Use jQuery to detect if your website is in SimpleCMS

Hi Simon,

So can you go into a little more detail what I can actually do with this?

Ryan

Re: Use jQuery to detect if your website is in SimpleCMS

Hi Ryan, it can be used for different things. You could use the code to detect if the site is being view through SimpleCMS then apply a class name to each editable area and then put a border on those areas, you could then tell your client those borders represent editable areas.

You could also use the code to prevent some of your JavaScript from being applied to the website, for example you may have an image slideshow and if you removed the slideshow code while in SimpleCMS the images could be listed one after the other so your client can easily edit each one.

I hope those examples help. Let us know if you have any suggestions, questions or problems.

Re: Use jQuery to detect if your website is in SimpleCMS

How can i disable a certain javascript (menu script) from loading, as its causing huge issues with the CMS?

Re: Use jQuery to detect if your website is in SimpleCMS

Hi, use the code at the top to either apply the menu script or not.