Most viewed questions in Java-Script

0 votes
1 answer

How to call jQuery UI Dialog with ASP.NET button postback?

Hello @kartik, To solve the problem with ASP:Button ...READ MORE

Apr 28, 2020 in Java-Script by Niroj
• 82,880 points
3,080 views
0 votes
1 answer

How do I check if an HTML element is empty using jQuery?

Hello @kartik, Try: if ($('#element').is(':empty')){ //do something }  If you ...READ MORE

Aug 25, 2020 in Java-Script by Niroj
• 82,880 points
3,077 views
0 votes
1 answer

How to check if a specific key is present in a hash or not?

Hello @kartik, While Hash#has_key? gets the job done, as it has ...READ MORE

Jul 24, 2020 in Java-Script by Niroj
• 82,880 points
3,018 views
0 votes
1 answer

How to trigger the window resize event in JavaScript?

Hello @kartik, Try this: window.dispatchEvent(new Event('resize') ...READ MORE

Aug 25, 2020 in Java-Script by Niroj
• 82,880 points
2,961 views
0 votes
1 answer

How is the 'use strict' statement interpreted in Node.js?

Hello @kartik, "use strict"; Basically it enables the strict ...READ MORE

Oct 8, 2020 in Java-Script by Niroj
• 82,880 points
2,948 views
0 votes
1 answer

How do I pass command line arguments to a Node.js program?

Hello @kartik, If your script is called myScript.js ...READ MORE

May 5, 2020 in Java-Script by Niroj
• 82,880 points
2,899 views
0 votes
1 answer

Error:Parsing JSON giving “unexpected token o” error

Hello @kartik, Your data is already an object. ...READ MORE

Jun 19, 2020 in Java-Script by Niroj
• 82,880 points
2,886 views
+1 vote
1 answer

How to download a file from NodeJS Server using Express?

Hello @kartik, Express has a helper for this as: app.get('/download', function(req, ...READ MORE

Sep 23, 2020 in Java-Script by Niroj
• 82,880 points
2,869 views
0 votes
1 answer

How to change programmatically the src of an img tag?

Hello @kartik, Give your img tag an id, ...READ MORE

Sep 4, 2020 in Java-Script by Niroj
• 82,880 points
2,799 views
0 votes
1 answer

How do I disable right click on my web page?

Hello @kartik, You can do that with JavaScript ...READ MORE

Sep 23, 2020 in Java-Script by Niroj
• 82,880 points
2,741 views
0 votes
1 answer

How to rollback a specific migration?

Hello @kartik, Try this: rake db:migrate:down VERSION=20100905201547 will roll back ...READ MORE

Jul 24, 2020 in Java-Script by Niroj
• 82,880 points
2,687 views
0 votes
0 answers

Uncaught TypeError: Cannot read property 'top' of undefined

I have two different kinds of sticky ...READ MORE

May 11, 2022 in Java-Script by Kichu
• 19,050 points
2,671 views
0 votes
1 answer

Open a URL in a new tab (and not a new window)

Nothing an author can do can choose ...READ MORE

Feb 23, 2022 in Java-Script by Aditya
• 7,680 points
2,645 views
0 votes
1 answer

Error:“Cross origin requests are only supported for HTTP”when loading a local file

Hii @kartik, You are loading the model using ...READ MORE

Jun 8, 2020 in Java-Script by Niroj
• 82,880 points
2,626 views
0 votes
1 answer

How to convert an Object {} to an Array [] of key-value pairs in JavaScript?

Hello @kartik, You can use Object.keys() and map() to do this var obj ...READ MORE

Sep 4, 2020 in Java-Script by Niroj
• 82,880 points
2,589 views
0 votes
1 answer

How to stop event propagation with inline onclick attribute?

Hello @kartik, Use event.stopPropagation(). <span onclick="event.stopPropagation(); alert('you clicked inside the ...READ MORE

Sep 23, 2020 in Java-Script by Niroj
• 82,880 points
2,565 views
0 votes
1 answer

Error :jquery's .ajax() method not sending my session cookie

Hello @kartik, AJAX calls only send Cookies if ...READ MORE

Aug 25, 2020 in Java-Script by Niroj
• 82,880 points
2,529 views
0 votes
1 answer

How can I Abort Ajax requests using jQuery?

Hello @kartik, It is always best practice to ...READ MORE

Jun 18, 2020 in Java-Script by Niroj
• 82,880 points
2,525 views
0 votes
1 answer

Error:Invariant Violation: _registerComponent(…): Target container is not a DOM element

Hii @kartik, Basically what you done is right, ...READ MORE

Jun 8, 2020 in Java-Script by Niroj
• 82,880 points
2,498 views
0 votes
1 answer

How to detect a 'touch screen' device using JavaScript?

Hello @kartik, Use this: function is_touch_device() { ...READ MORE

Sep 18, 2020 in Java-Script by Niroj
• 82,880 points
2,421 views
0 votes
1 answer

How do I post a form in laravel 5 using ajax?

Hello @kartik, You can solve this error by ...READ MORE

Jun 11, 2020 in Java-Script by Niroj
• 82,880 points
2,418 views
0 votes
1 answer

How to Change the selected value of a drop-down list with jQuery?

Hello @kartik, With hidden field you need to ...READ MORE

Sep 9, 2020 in Java-Script by Niroj
• 82,880 points
2,390 views
0 votes
1 answer

Why are preload link not working for JSON requests ?

Hii @kartik, You have to add as="fetch" for JSON files. ...READ MORE

Jun 19, 2020 in Java-Script by Niroj
• 82,880 points
2,383 views
0 votes
1 answer

How to get the browser to navigate to URL in JavaScript?

Hii, This works in all browsers: window.location.href = '...'; If ...READ MORE

May 28, 2020 in Java-Script by Niroj
• 82,880 points
2,378 views
0 votes
1 answer

Error:“Access is denied” error on accessing iframe document object

Hello @kartik, Basically, this error occurs when the ...READ MORE

Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
2,329 views
0 votes
1 answer

What is an appropriate content-type header for JavaScript files?

Hello @kartik, JS has two registered MIME types:  The ...READ MORE

Jul 7, 2020 in Java-Script by Niroj
• 82,880 points
2,300 views
0 votes
1 answer

How to Determine if page is valid in JavaScript - ASP.NET?

Hello @kartik,  Make the call on an input ...READ MORE

Sep 9, 2020 in Java-Script by Niroj
• 82,880 points
2,283 views
0 votes
1 answer

How to dynamically load JS inside JS?

Hello @kartik, The script is not added to ...READ MORE

Aug 25, 2020 in Java-Script by Niroj
• 82,880 points
2,194 views
0 votes
1 answer

How to print a circular structure in a JSON-like format?

Hello, You can use util.inspect(object) in node.js. It automatically ...READ MORE

Apr 24, 2020 in Java-Script by Niroj
• 82,880 points
2,180 views
0 votes
1 answer

How to get function parameter names/values dynamically?

Hello @kartik, The following function will return an ...READ MORE

Sep 23, 2020 in Java-Script by Niroj
• 82,880 points
2,150 views
0 votes
1 answer

How to return JSON with ASP.NET & jQuery?

Hello @kartik, You need to do something like ...READ MORE

Sep 9, 2020 in Java-Script by Niroj
• 82,880 points
2,083 views
0 votes
1 answer

How do I search for a key of object in javascript?

Use hasOwnProperty(key) for (let i = 0; i ...READ MORE

Oct 14, 2020 in Java-Script by Niroj
• 82,880 points
2,071 views
0 votes
1 answer

JavaScript equivalent of PHP's preg_replace

Hello @klartik, Jusr use the global flag, g: foo.replace(/<br>/g,"\n") Hope it ...READ MORE

Jul 6, 2020 in Java-Script by Niroj
• 82,880 points
2,044 views
0 votes
1 answer

Hi, how does one kill the whatsapp message loop with a code instead of closing whatsapp-web?

Hello @Felix , Use this code: <script> function simulateMouseEvents(element, eventName) ...READ MORE

Oct 20, 2020 in Java-Script by Niroj
• 82,880 points
2,034 views
0 votes
1 answer

How to access GET directly from JavaScript?

Hello @kartik, You can first go through: window.location.search It will ...READ MORE

Apr 29, 2020 in Java-Script by Niroj
• 82,880 points
1,985 views
0 votes
1 answer

Error:Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers

Hello @kartik, Access-Control-Allow-Headers does not allow * as accepted value. Instead of ...READ MORE

Jul 6, 2020 in Java-Script by Niroj
• 82,880 points
1,969 views
0 votes
1 answer

How to do API call in react js?

Hello, Use fetch method inside componentDidMount to update state: componentDidMount(){ fetch('https://dey.me/api/') ...READ MORE

May 18, 2020 in Java-Script by Niroj
• 82,880 points
1,921 views
0 votes
1 answer

How to remove all child elements of a DOM node in JavaScript?

Hello @kartik, Use modern Javascript, with remove! const parent = ...READ MORE

Sep 21, 2020 in Java-Script by Niroj
• 82,880 points
1,873 views
0 votes
1 answer

Error:“Access is denied” error on accessing iframe document object

Hii @kartik, The problem was that even though the ...READ MORE

Jun 19, 2020 in Java-Script by Niroj
• 82,880 points
1,852 views
0 votes
1 answer

How can I determine the type of an HTML element in JavaScript?

Hello @kartik, nodeName is the attribute you are looking ...READ MORE

Oct 8, 2020 in Java-Script by Niroj
• 82,880 points
1,843 views
0 votes
1 answer

How to set outerHTML with jQuery?

hello @kartik, This is innterHTML because it's inside ...READ MORE

Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
1,826 views
0 votes
1 answer

How can I check whether a radio button is selected with JavaScript?

Hello @kartik, You can use vanilla JavaScript way var radios ...READ MORE

Sep 3, 2020 in Java-Script by Niroj
• 82,880 points
1,822 views
0 votes
1 answer

How do I use format() on a moment.js duration?

Hello @kartik, Use this: // set up let start = ...READ MORE

Oct 7, 2020 in Java-Script by Niroj
• 82,880 points
1,789 views
0 votes
1 answer

How to reject in async/await syntax?

Hello @kartik,  throw an Error wrapping the value, which results in ...READ MORE

Sep 23, 2020 in Java-Script by Niroj
• 82,880 points
1,789 views
0 votes
1 answer

How to disable postback on an asp Button in System.Web.UI.WebControls.Button?

Hello @kartik, Use this: <asp:button runat="server".... OnClientClick="myfunction(); return false;" ...READ MORE

Sep 9, 2020 in Java-Script by Niroj
• 82,880 points
1,770 views
0 votes
1 answer

How to get browser width using JavaScript code?

Hello @kartik, Use this code: var w = window.innerWidth; var ...READ MORE

Oct 9, 2020 in Java-Script by Niroj
• 82,880 points
1,764 views
0 votes
1 answer

How to uncheck a radio button?

Hello @kartik, either (plain js) this.checked = false; or (jQuery) $(this).prop('checked', ...READ MORE

Sep 18, 2020 in Java-Script by Niroj
• 82,880 points
1,676 views
0 votes
2 answers

How to animate a change in backgroundColor using jQuery on mouseover?

You don't need jquery. You can also ...READ MORE

Sep 9, 2020 in Java-Script by Eureka
• 160 points
1,621 views
+1 vote
1 answer

How to Check synchronously if file/directory exists in Node.js?

Hello, You can use fs.existsSync(): const fs = require("fs"); // ...READ MORE

May 28, 2020 in Java-Script by Niroj
• 82,880 points
1,617 views
0 votes
1 answer

How do you access the matched groups in a JavaScript regular expression?

Hello, Here’s a method you can use to ...READ MORE

May 28, 2020 in Java-Script by Niroj
• 82,880 points
1,613 views