Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Javascript Articles - Page 592 of 671
179 Views
A regular expression is an object that describes a pattern of characters.The JavaScript RegExp class represents regular expressions, and both String and RegExp define methods that use regular expressions to perform powerful pattern-matching and search-and-replace functions on the text. A regular expression could be defined with the RegExp () constructor, as follows −var pattern = new RegExp(pattern, attributes); or var pattern = /pattern/attributes;The following are the parameters −pattern − A string that specifies the pattern of the regular expression or another regular expression.attributes − An optional string containing any of the "g", "i", and "m" attributes that specify ... Read More
168 Views
To convert a date to a string using the universal time convention, use the toUTCString() method. It returns converted the date to a string, using the universal time convention.ExampleYou can try to run the following code to learn how to convert a date to a string using UTC − JavaScript toUTCString Method var dateobject = new Date(2018, 0, 15, 14, 39, 7); document.write( dateobject.toUTCString() );
162 Views
The ondrop event triggers when a dragged element is dropped on the target. You can try to run the following code to learn how to implement ondrop event in JavaScript −ExampleLive Demo .drag { float: left; width: 100px; height: 35px; border: 2px dashed #876587; margin: 15px; padding: 10px; } ... Read More
110 Views
To return the “time” portion of the Date as a human-readable string, use the toTimeString() method in JavaScript. This method returns the time portion of a Date object in the human-readable form.ExampleYou need to run the following code to return only the time portion of a Date − JavaScript toTimeString Method var dateobject = new Date(2018, 0, 1, 14, 39, 7); document.write( dateobject.toTimeString() );
232 Views
The window.history object is used to go back or to the next page of the web browser. It has the browser's history and comes with the following two methods −history.back − Go to previous URLhistory.next − Go to next URLExampleYou can try to run the following code to learn how to work with window.history object in JavaScript −Live Demo function backPage() { window.history.back() } function nextPage() { window.history.next() }
794 Views
In this tutorial, we will learn to load the next page in the history list in JavaScript. The Window object in JavaScript accesses the window in the browser. This object contains many properties and methods required to do the tasks. The Window object also retrieves the information from the browser window. There is a history stack in every browser that saves the pages visited by the user. To access this history stack, we can use the history object that is the property of the Window object. By accessing the history from the browser, we can go to the next or ... Read More
95 Views
ignoreCase is a read-only boolean property of RegExp objects. It specifies whether a particular regular expression performs case-insensitive matching, i.e., whether it was created with the "i" attribute.ExampleYou can try to run the following code to learn how to work with Ignore Case RegExp property in JavaScript. JavaScript RegExp ignoreCase Property var re = new RegExp( "string" ); if ( re.ignoreCase ) { document.write("Test1-ignoreCase property is set"); } ... Read More
162 Views
The source RegExp property in JavaScript is a read-only string property of RegExp objects. It contains the text of the RegExp pattern. This text does not include the delimiting slashes used in regular-expression literals, and it does not include the "g", "i", and "m" attributes.ExampleYou can try to run the following code to learn how to implement source RegExp property in JavaScript − JavaScript RegExp source Property var str = "JavaScript is an interesting scripting language"; var re = new RegExp( "script", "g" ); re.test(str); document.write("The regular expression is : " + re.source);
89 Views
Use the screen.availHeight property to return the width of the user’s screen. The result will be in pixels and Taskbar feature won’t be included.ExampleYou can try to run the following code to learn how to work with the screen.availHeight property in JavaScript −Live Demo document.write("Height of the screen: "+screen.availHeight);
341 Views
If you want to get the pixels of the document scrolled to from the upper left corner of the window, then use the pageXoffset and pageYoffset property. Use pageYoffset for vertical pixels.ExampleYou can try to run the following code to learn how to work with pageYOffset property in JavaScript.Live Demo div { background-color: green; height: 1500px; width: 1500px; } function scrollFunc() { window.scrollBy(200, 200); alert("Vertical: " + window.pageYOffset); } Scroll