Niq's OA Resources

OA Content Replacement

To have content toggle depending on the the url parameters of a website, use the code below. The style should go first so none of the content 'pops in' before becoming hidden. Each block of content that is to be shown conditionally on the page must be surrounded with a div with the class of "OAC". Then the script, and its initialization after.

Then add the class "oacDefault" to the OAC div that will have the default content that shows when there is no url parameter, or no matching url parameters. For each set of content after that that is supposed be shown depending on the url parameters, create a new class to add to that.

Then, in the initialization script, define what the url parameters are, that are to be met (excluding the "?"), and the class name of the div surrounding the content that's supposed to appear with that url parameter.

Important Note:

The script will only show one of the content divs, and remove the rest, and it goes though each parameter listed in order. So if the url parameter meets more than one criteria in the script, it will do the first instance it matches, then remove the rest and end. So if you want a div for matching multiple url parameters (like the first option in the example), it's recommended to put that in the list first.


Try out the buttons below to see a simplified form of this in action.

oacDefault
oac1
oac2
oac3