Programming Scripts Articles

Page 19 of 33

HTML5 Cross Browser iframe post message - child to parent?

George John
George John
Updated on 24-Jan-2020 231 Views

The parent object provides a reference to the main window from the child.The following is the parent code. The directive below triggers the iFrame to send a message to the parent window every 3 seconds. No initial message from the main window needed!var a= window.addEventListener ? "addEventListener" : "attachEvent";// here a is the event method var b= window[a];// here b is the eventer var c= a== "attachEvent" ? "onmessage" : "message";// here c is the message event // Listen to message from child window b (c, function(e) {    var d= e.message ? "message" : "data";// here d is ...

Read More

Zoom HTML5 Canvas to Mouse Cursor

Ankith Reddy
Ankith Reddy
Updated on 24-Jan-2020 1K+ Views

The canvas always scales from its current origin. The default origin is [0, 0]. If you want to scale from another point, you can first do ctx.translate(desiredX, desiredY);. This will reset the origin of the canvas to [desiredX, desiredY].The translate() method remaps the (0, 0) position on the canvas. The scale() method scales the current drawing, bigger or smaller. If you want to translate() the canvas context by your offset, you need to first scale() it to zoom in or out, and then translate() back by the opposite of the mouse offset.These steps are given in the following examplectx.translate(pt.x, pt.y); ...

Read More

AngularJS and HTML5 date input value - how to get Firefox to show a readable date value in a date input?

Ankith Reddy
Ankith Reddy
Updated on 24-Jan-2020 309 Views

The elements of type date allows user to enter date, using a text box or using date picker. With the ng-model directive, bins the values of AngularJS application data to HTML input controls. Firefox does not currently support type="date". It will convert all the values to string. Sinceyou want date to be a real Date object and not a string, so we create another variable, and then link the two variables as done in the below given code function MainCtrl($scope, dateFilter) {    $scope.date = new Date();    $scope.$watch('date', function (date){       $scope.dateString = dateFilter(date, 'yyyy-MM-dd');   ...

Read More

Can you take a screenshot of the page using HTML5 Canvas?

George John
George John
Updated on 24-Jan-2020 699 Views

Html2Canvas is a JavaScript library that can take screenshot of the whole web page or specific part. It doesn’t take the screenshot but creates the view based on the page information.ExampleBelow given is an example code. Here, html2canvas.js script is included at the . The html2canvas() method is called. Returns the base64 value, which eventually creates image source or an image file.                         Take screenshot                                                      function screenshot(){             html2canvas(document.body).then(function(canvas) {                document.body.appendChild(canvas);             });          }          

Read More

Does HTML5 Canvas support Double Buffering?

Chandu yadav
Chandu yadav
Updated on 24-Jan-2020 650 Views

For double buffering on the canvas, create a 2nd canvas element and draw to it. After that draw the image to the first canvas using the drawImage() method,// canvas element var canvas1 = document.getElementById('canvas'); var context1 = canvas1.getContext('2d'); // buffer canvas var canvas2 = document.createElement('canvas'); canvas2.width = 250; canvas2.height =250; var context2 = canvas2.getContext('2d'); // create on the canvas context2.beginPath(); context2.moveTo(10,10); context2.lineTo(10,30); context2.stroke(); //render the buffered canvas context1.drawImage(canvas2, 0, 0);

Read More

How To Install Parse Server on Ubuntu

Sharon Christine
Sharon Christine
Updated on 23-Jan-2020 452 Views

Parse server is an open source and is like mobile back-end. It is owned by Facebook since 2013. This server may be deployed to any infrastructure that may run Node.Js and MongoDB. This article explains about – How To Install Parse Server on Ubuntu.Prerequisitespython-software-properties packageNode.jsMongoDBTo add python-software-properties package, use the following command-$ sudo apt-get install build-essential git python-software-propertiesThe sample output should be like this –Reading package lists... Done Building dependency tree Reading state information... Done build-essential is already the newest version (12.1ubuntu2). build-essential set to manually installed. The following packages were automatically installed and are no longer required:    linux-headers-4.4.0-31 ...

Read More

Technologies Commonly Used by Startups

karthikeya Boyini
karthikeya Boyini
Updated on 23-Jan-2020 838 Views

As you decide on the factors affecting your choices, you can now narrow down from the technology options available to a controllable set. It is imperative for startups to take on best practices along with choosing the right technology (tech.) stacks for their business to grow.Typical Tech StackApplications have two ends – the front-end (client side) and the back-end (server side). For eg. on the server side, the applications could be the operating system, the web server, database, programming language and the web framework. These are stacked one on the top of the other with the web framework at the ...

Read More

Match any single character outside the given set.

Rama Giri
Rama Giri
Updated on 20-Jan-2020 135 Views

To match any single character outside the given set with JavaScript RegExp, use the [^aeiou] metacharacter.Example           JavaScript Regular Expression                        var myStr = "Welcome!";          var reg = /[^lc]/g;          var match = myStr.match(reg);                   document.write(match);          

Read More

Match any string containing a sequence of two to three p's.

Akshaya Akki
Akshaya Akki
Updated on 20-Jan-2020 138 Views

To match any string containing a sequence of two to three p’s with JavaScript RegExp, use the p{2,3} Quantifier.Example           JavaScript Regular Expression                        var myStr = "Welcome 1, 10, 100, 1000, 1000";          var reg = /\d{2,3}/g;          var match = myStr.match(reg);                    document.write(match);          

Read More

How can I add debugging code to my JavaScript?

Krantik Chavan
Krantik Chavan
Updated on 17-Jan-2020 247 Views

To add debugging code to JavaScript, use the alert() or document.write() methods in your program. For example,var debugging = true; var whichImage = "widget"; if( debugging ) alert( "Calls swapImage() with argument: " + whichImage ); var swapStatus = swapImage( whichImage ); if( debugging ) alert( "Exits swapImage() with swapStatus=" + swapStatus );Examine the content and order of the alert() as they appear, you can examine the health of your program very easily.

Read More
Showing 181–190 of 328 articles
« Prev 1 17 18 19 20 21 33 Next »
Advertisements