When We build a web application, we do not want the users to use the right button of the mouse.Today, many of the code examples used to disable the right-click no longer work in most browsers and browsers such as Opera do not allow the right-mouse button to be disabled. Anyway we can disable right click using jQuery or JavaScript.
Tag » Functionality
Automatic Update Copyright Year
Still wonder how to automatic update copyright year instead of changing hard-coded value each year. Lol!! You need some fresh air to let your mind breathe. Use PHP’s date() function which can echo the current year in your copyright text.
Copyright ©< ?php echo date('Y'); ?> | Your Company Name
Convert an image to grayscale using CSS
Here is simple CSS rule to convert an image to grayscale using CSS or making image appear as black and white. As far as CSS filters are supported in webkit browsers, this solution is cross-browser.
Prevent popup window from getting close by escape key
By default an opened modal popup window gets close whenever an user presses ESC key on keyboard. In some cases we need to prevent popup window from getting close by escape key as a part of our requirements. Here I have written two methods to disable the function of ESC key using JavaScript and jQuery each.
How to check if a page exists by url?
There may be a situation when you need to display content based on existence of a page or custom post by url. As the example below there are two different parent pages for the same page slug. We assume that certain pages will have the same title, and just have different parent pages. So we want to check if a page exists by url?
How to pass variables to get_template_part() in WordPress
Ok! So you need to pass variables to get_template_part() in WordPress. Sorry because get_template_part() is not made to accept variables or arguments. But here is a better way to achieve the same using WordPress’s locate_template() function within PHP’s include().
Implement styles on parent tag if it has children
We need to implement the css things based on the condition that the parent tag has a child or not. For the same,I faced an issue of implement styles on parent tag if it has children.
I found many tutorials for solving this problem using jQuery or javascript. But I was looking the solution using css.
Prevent anchor in an iframe from scrolling the parent window
I was building a page in a website. In that page I was loading a page inside an iframe. The page inside iframe had an anchor (http:/fellowtuts.com/test.html#specific_content) as well. When I used to click on the anchors within the iframe to reach the specific content section, it was working in firefox browser smoothly but working with a undesired behaviour in chrome and internet explorer browsers. In chrome, it was scrolling the parent window to top along with Iframe’s content.
Offsetting anchor hash tag links to adjust for fixed header
Sometimes our website has a fixed header or navigation menu that usually remains fixed at the top of the page. When you use the URL anchor (the #fragment part), the browser window will scroll itself (instantly) to bring anchor at the top of the page, leaving the content behind the fixed header. So here we need for offsetting anchor hash tag links to adjust for fixed header to let content appear below the fixed item.
How to detect the screen resolution with javascript
In javascript, the screen.width and screen.height properties contain the size of a visitor’s monitor is set to. Bear in mind that the size of the monitor is set to, is not the same as the size of the browser window a visitor is using as windows can of course be set to different sizes. To get screen resolution with javascript we need to get the height and width of the viewport which depends on browser.