jQWidgets jqxBarcode getDataURL() Method
Last Updated :
13 Sep, 2022
jQWidgets is a JavaScript framework for making web-based applications for PC and mobile devices. It is a very powerful, optimized, platform-independent, and widely supported framework. The jqxBarcode is used to indicate a widget that can display various forms of bar codes.
The getDataURL() method is used to return the base64 string of the displayed QR code. It returns a string value.
Syntax:
var getDataURL = $('Selector').jqxBarcode("getDataURL", "format");
Parameters:
- format: It is the stated data URL format of the base64 string which is to be returned. For example, svg, png, or jpg. It is of type string.
Return type: This method returns a String value.
Linked Files: Download jQWidgets from the given link. In the HTML file, locate the script files in the downloaded folder.
<link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<script type=”text/javascript” src=”scripts/jquery-1.11.1.min.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcore.js”> </script>
<script type=”text/javascript” src=”jqwidgets/jqxbarcode.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxbuttons.js”></script>
Example 1: The below example illustrates the jqxBarcode getDataURL() method in jQWidgets.
HTML
<!DOCTYPE html>
< html lang = "en" >
< head >
< link rel = "stylesheet"
href = "jqwidgets/styles/jqx.base.css"
type = "text/css" />
< script type = "text/javascript"
src = "jqwidgets/jqxcore.js" >
</ script >
< script type = "text/javascript"
src = "scripts/jquery-1.11.1.min.js" >
</ script >
< script type = "text/javascript"
src = "jqwidgets/jqxbarcode.js" >
</ script >
< script type = "text/javascript"
src = "jqwidgets/jqxbuttons.js" >
</ script >
</ head >
< body >
< center >
< h1 style = "color:green" >
GeeksforGeeks
</ h1 >
< h3 >jQWidgets jqxBarcode getDataURL() method </ h3 >
< div id = "jqxb" ></ div >
< input type = "button" style = "margin:29px;"
id = "jqxbtn" value = "Click here" />
< div id = "log" ></ div >
</ center >
< script type = "text/javascript" >
$(document).ready(function () {
$("#jqxb").jqxBarcode({
value: "code128d",
});
$("#jqxbtn").jqxButton({
width: 280
});
$("#jqxbtn").on("click", function () {
var g = $('#jqxb').
jqxBarcode('getDataURL', "svg");
$('#log').text(g);
});
});
</ script >
</ body >
</ html >
|
Output:
Example 2: The following is another example of the jqxBarcode getDataURL() method in jQWidgets.
HTML
<!DOCTYPE html>
< html lang = "en" >
< head >
< link rel = "stylesheet"
href = "jqwidgets/styles/jqx.base.css"
type = "text/css" />
< script type = "text/javascript"
src = "jqwidgets/jqxcore.js" >
</ script >
< script type = "text/javascript"
src = "scripts/jquery-1.11.1.min.js" >
</ script >
< script type = "text/javascript"
src = "jqwidgets/jqxbarcode.js" >
</ script >
< script type = "text/javascript"
src = "jqwidgets/jqxbuttons.js" >
</ script >
</ head >
< body >
< center >
< h1 style = "color:green" >
GeeksforGeeks
</ h1 >
< h3 >jQWidgets jqxBarcode getDataURL() method </ h3 >
< div id = "jqxb" ></ div >
< input type = "button" style = "margin:29px;"
id = "jqxbtn" value = "Click here" />
< div id = "log" ></ div >
</ center >
< script type = "text/javascript" >
$(document).ready(function () {
$("#jqxb").jqxBarcode({
value: "code128d",
});
$("#jqxbtn").jqxButton({
width: 280
});
$("#jqxbtn").on("click", function () {
var format = null;
var g = $('#jqxb').
jqxBarcode('getDataURL', format);
if (format === null) {
$('#log').text("Null!");
}
else {
$('#log').text("Not null!");
}
});
});
</ script >
</ body >
</ html >
|
Output:
Reference: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxbarcode/jqxbarcode-api.htm?search=
Share your thoughts in the comments
Please Login to comment...