Tuesday, February 14, 2017

NOSCRIPT tag in HTML

This <noscript> tag defines the enable of javaScript in your browser. To state whether JavaScript is enabled or not in your browser we can use this tag. This works fully independently, means no other JavaScript or JQuery library are not needed to use this facility.


First create a HTML page with JavaScript functionality and a noscript tag.


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>NoScript Example</title>
</head>
<body>
    <noscript>
        Javascript is either disabled or not supported in your browser.
        Please enable it or use a Javascript enabled browser.
    </noscript>
    <div>
        This is a HTML page.
    </div>
    <script>
        alert('JavaScript is working!');
    </script>
</body>
</html>


Now run the HTML page in browser and HTML content will display followed by a pop up showing "JavaScript is working".


Notice the text within noscript is not showing in the browser. Now disable the JavaScript in browser.
For Chrome go to Advance Settings->Privacy->Content Settings->JavaScript and select "Do not allow any site to run JavaScript". Hit OK and refresh the page.




Now you can see the text within nosript tag and notice no popup will be there as you disabled the JavaScript.


For Mozilla visit this link, and for Internet Explorer visit this link


Browser Dependency:
This HTML tag supports all the front line browsers like,
  • Chrome
  • Android
  • Firefox
  • Firefox Mobile
  • Internet Explorer (IE)
  • IE Phone
  • Opera
  • Opera Mobile
  • Safari
  • Safari Mobile









How to find next focusable item in HTML using JQuery

In this post we will found how to find the next focusable item and focus into that element in HTML using JQuery. Among lots of element sometime its getting necessary to focus on the next element on some ENTER or TAB click in HTML. So, how to do this. Let’s find out.


First create a HTML page with few dummy elements.

<div id="div1">
    1.<input type="text" />
    2.<input type="text" />
</div>
<div id="div2">
    3.<input type="text" id="input3" />
    4.<a href="#">Anchor</a>
    5.<input type="text" />
</div>


We have designed a HTML page with different focusable elements (textbox and anchor) and different sections (div1 & div2).


Now as per HTML structure the TAB will go from first text box to last text box. But how programmatically we will find the next focusable item after a certain element.


 var nextTabbable = $("#input3").next(":tabbable").length
                    ? $("#input3").next(":tabbable")
                    : $("#input3").parent().next().find(":tabbable").first();


Using "tabbable" we can find the next focusable or tabbable item in the HTML structure. So  nextTabbable  is the item which is next after "input3" in this structure. Now write your desired code upon that. For more information please visit :tabbable Selector.


How to make a HTML element focusable

Input elements like text box, textarea, button, anchor drop down list(select), list are pre focusable element in HTML. But elements like span, div, label these are not focusable element, as these are not interacting with user directly. These are only use to show output. According to new American Disability Act (ADA) any disabled person can access the website as an able person does. So, in this case we have to make the site totally focusable so that a disable person can operate the whole website using only TAB and ENTER key.


Now in case of focusable items there is no problem, but for other items we can use TabIndex.


Just put tabindex="0" to each and every element of the page which should be focusable. TabIndex="0" implies that the element will be under focusable elements and also the first element of the page. But don't worry a page can have more than one element having tabindex="0". To make manual tabbing you can use tabindex="1", tabindex="2", tabindex="3" and so on.


Now if you are working on an existing project then it’s hard to set all the elements as tabindex="0" so on that case you can do two things.


1. Using Class.
Name those elements, which are need to be focusable, with a class name. Let’s say "focusable" is the class name.


Now on the ready method of you JQuery put the below line to comply.


$('.focusable').prop('tabindex','0');


This line of code will add tabindex property with value zero into those element which has been marked with the class name "focusable". And all the site will be ready to navigate using TAB.


2. Using JQuery selector
If there are lots of elements to be focused then you can use selectors like "div", "label", "span".


$("div, label, span").prop("tabindex","0");


Like this aim can be achieved and in this case all the elements will be under navigation. If you have your own tags used in the page then you can add those too.

Monday, June 20, 2016

Run Stored Procedure from Batch file (MS SQL & Oracle)

In this post we will lean how to run a stored procedure from a batch file (.bat) externally. This is used very often to run a schedule job set in the server. The whole job logic is written in the Stored procedure and we are executing that from an external batch file. So what we have to do to run this, lets see.

We will use the sqlcmd.exe file to run the stored procedure from command.  First of all create a Stored procedure in your MS. SQL server.



CREATE PROCEDURE SP_TESTSP
AS
BEGIN
      print 'THIS IS A TEST MESSAGE. LOGGED AT ' + CONVERT(VARCHAR, getdate(), 120)
END
GO


I named this as SP_TESTSP, go with your name and now open a Notepad or any other editor and write down the following script.



sqlcmd -Q "exec <STORED PROCEDURE NAME>" -S <SERVER NAME> -d <DATABSE NAME> -o <OUTPUT FILE NAME WITH PATH>


As my server name "arka-PC\SQLEXPRESS" and using Database as "DEMO", so in this case the command will be,



sqlcmd -Q "exec SP_TESTSP" -S arka-PC\SQLEXPRESS -d Attendance -o D:\SPOutput.txt


Before run this script create a file name with SPOutput.txt in the D:\ drive or where you want to save. The output of the stored procedure will be captured.

Now save the file with an extension of  ".bat". Set all the privileges and run the file by clicking twice. Check the log file, it will contain the result of the executed stored procedure.

Output:



THIS IS TEST MESSAGE. LOGGED AT 2016-06-19 23:52:48


In the next tutorial we will see how to put a bat file in a Task Scheduler in windows server.

Follow by Email

Popular Posts

Pageviews