Showing posts with label html. Show all posts
Showing posts with label html. Show all posts

Monday, June 10, 2013

Disable right click on link anchor a tag

I have a link that I use a jQuery plugin to open in a popup window and that's how it is to be used. So in order to prevent users to right click and open it in a new window I wanted to disable right click on my anchor tag.. the solution is simple.. add 'oncontextmenu="return false"'

<a href='myLink.php' oncontextmenu="return false">Click me</a>

Thursday, July 26, 2012

HTML is stripped in Joomla component configuration / parameters filter

If you are looking to add HTML anywhere in Joomla and 'text filtering' option in 'global configuration' is failing then here is what you need to do

You need to add a filter='safehtml' in your field tag be it your component field or parameter e.g.

<field menu="hide" name="sharethisbtncode" type="textarea"  filter="SAFEHTML" label="Sharethis Buttons Code" description="HTML buttons code of the buttons needed to be displayed" />

Without it Joomla will use the default and strip HTML.

Also know that it will only work for simple HTML like in this example buttons code, if you are looking for including something like javascript like header of analytics or some other you will need to use filter="RAW"

Following is the list of all the filter options:


case 'RULES': // Used for permissions etc
case 'UNSET': // Does nothing.
case 'RAW': // No Filter.
case 'SAFEHTML': // Filter safe HTML.
case 'SERVER_UTC': // Convert a date to UTC based on the server timezone offset.
case 'USER_UTC': // Convert a date to UTC based on the user timezone offset.
default: // Check for a custom callback filter that you can write


For more details refer to:
http://docs.joomla.org/API16:JForm/filter

Include js in head tag Joomla 2.5

If you are looking for how to include javascript in the head tag of html without having to write it in the template for features like sharethis, Google analytics here is how to

Simply use the following two lines:

$document = &JFactory::getDocument();
$document->addCustomTag('<script type="text/javascript">my javascript</script>');

And it will add javascript to the head tag.

You can also include js/css files by using

$document->addStyleSheet('path');
$document->addScript('path');

Tuesday, July 24, 2012

[Solved] DIV background color not showing

If you have a div tag that has background-color set but it doesn't show at all because there is dynamic content in it with some further tags that have content in it and hence you can not set a fixed height e.g.

<div class="bgcolorRed">
      <div>...content....</div>
      <dl>.....content....</dl>
</div>

Just simply add 'overflow: hidden' along with you background color in CSS and it will work
i.e.

.bgcolorRed {
     background-color: red;
     overflow: hidden;
}

Hope that helps.