New answers tagged javascript
Score of 0
0
votes
Finding all indexes of a specified character within a string
I was having the same problem. I have a page with search results in which I want to highlight the search termse. I wrote the following code with alteration based on the initial question.
var ...
Score of 1
1
vote
TypeError: Cannot read property 'access_token' of undefined
The issue is that router.use runs on all the requests, including the home page, login redirect and auth callback before the cookie is even set.
When the cookie is not set, key is undefined, and ...
Score of -2
-2
votes
Stripe Connect onboarding works in test mode but redirects to login in live mode
Try using Stripe`s Connect embedded components instead of redirecting users to a Stripe login page. Also you need to show your code, if you want the most accurate advice
Score of 4
4
votes
Can users pretend they have a different location with navigator.geolocation or is it save?
Anything done in client-side JavaScript can be overridden by the user, you can't trust it for any security-related purpose.
Some IP geolocation services can identify VPN addresses -- I think MaxMind ...
Score of 0
0
votes
Javascript full stack
The main problem is that updateClickerImage() is not being called when xpAutoClickerPerSecond changes.
Update your function:
function updateClickerImage() {
const clickImg = document....
Score of 5
5
votes
Accepted
Is redirecting using JavaScript to a URL with a fragment prohibited?
When you navigate in any way to a URL with a fragment and the rest of the URL is the same as the current page, the browser scrolls to that fragment on the same page without triggering a page load.
You ...
Ry-♦
- 227k reputation score 226555
Score of 0
0
votes
Align div with fixed position on the right side
As @246tNt mentioned: You can use two imbricated div.
Then use negative margin to make the fixed element positionable:
<div style='text-align: right;'>
<div style='display: inline-block;
...
Score of 1
1
vote
Vue.js watcher not detecting changes to nested object property
The user watcher is shallow by default. It only fires when the user object itself is reassigned, so mutating a nested property like user.name won't trigger it.
To catch nested mutations, use deep: ...
Score of 0
0
votes
How to reset ContentControl.Color to default?
The starting point here IMO is that in the Word object model there is a value called "wdColorAutomatic", which, if you could apply it, would do what you wanted, i.e. reset the contentcontrol....
Score of -1
-1
votes
How to 'polyfill' `interactive-widget=resizes-content` for meta viewport tag on iOS Safari?
There is no full polyfill — you can't make Safari actually shrink the layout viewport the way interactive-widget=resizes-content does on Chrome. But for the most common real-world need (keeping a ...
Score of 0
0
votes
Is there a way to Tailwind styles from spilling over into other applications? (Isolating tailwind styles to component library)
In Tailwind CSS, prefix lets you distinguish Tailwind utility classes from other custom CSS classes.
In v4, with CSS-first configuration, you can define prefix together with @import "tailwindcss&...
Score of 2
2
votes
What is the earliest point at which the browser calls requestAnimationFrame?
After looking through section 8.12 Animation Frames, I'm not seeing an explicit description of when you can call this. Mozilla Developer Network has a good write-up; from the intro:
The window....
Score of 1
1
vote
Accepted
How to query a custom element's internal elements while in the document from a DOMParser()?
I stripped your code to understand what you are trying to achieve.
I presume you want to load an external .mp3 file and control playing
I don't understand your <script> stuff.
And the use of ...
Score of 0
0
votes
SVG masked progress bar
I don't think there is much of a "SVG mastery" needed here. The moment you have the shape of a single "bar", just put it into mask-image and let CSS do the repeat. Optionally round ...
Score of 0
0
votes
CodeIgniter view is neither showing query results, nor updating html table rows from AJAX requests
Your controller method is unconditionally calling your view file (which I presume contains all of the page elements in addition to your model result data). If you want to re-use the same controller ...
Score of 0
0
votes
How can I detect back navigation on the client?
I know this is a very old question but I hit a similar issue in that my server was taking so long to produce the next page (lots of SQL queries on big data) that I had to pop up a "Please wait&...
Score of -1
-1
votes
How to delete an item from array only on the second click on the same element in React?
Your handler only does deletes, and there is no branch that selects, so selectedCountry?.Id === id can never be true unless something else sets it. That's why the first click appears to do nothing.
...
Score of 1
1
vote
How to delete an item from array only on the second click on the same element in React?
Maybe you shall just
currentItem = null
function handleClick(item){
if(currentItem === null)
setCurrentItem()
return;
if(currentItem === item)
list.filter(listItem => ...
Score of 0
0
votes
Accepted
How to populate an HTML input value from a text file using JavaScript
As you are already reading the file, and you want to populate the inputs while reading the data from the file. If your file is structured like this:
host: 192.168.0.189 -port: 9000
username: wan
...
Score of 1
1
vote
can I make choosing a file count as a user gesture?
No. A change event on a file input isn't a user gesture, so requestFullscreen() will reject inside your readFile logic. The initial click that opened the file picker expires by the time the change ...
Score of 0
0
votes
How are Playwright features being used in test automation?
The existing answer covers the principles well. I want to add some points on how you find these problems. Measure flakiness, retries hide flake by turning it into a pass, so turn them off periodically ...
Score of 0
0
votes
The event loop, call stack, and setTimeout of 0 or some small value
Yes, guaranteed.setTimeout always waits for the call stack to empty. Since First() is still running after calling Second(), CallBack can't fire until First() fully finishes
Score of 2
2
votes
Creating tiptap node for custom HTML
A Tiptap maintainer confirms in discussion #2272 that the array syntax always escapes strings, but you can return a real DOM node from renderHTML instead and set innerHTML on it
export const ...
Score of 0
0
votes
Accepted
How to repeat-print a string with a number in it that increases with each repeat-print, everything inside a .replace constraint
This code produces the expected result. How it works is explained further below:
const result =
'h1 h2 h3 h4 words words words words'
.replace(/abc/, '')
.replace(/[^]+/, _ => {
const NUM = Math....
Score of 1
1
vote
Accepted
I'm getting the error The asset "./components/index.jsx.js" is not present in the asset pipeline
The issue is that Rails is treating components/index.jsx as the logical asset name and then appending .js, so it ends up looking for:
components/index.jsx.js
The source file itself is fine:
app/...
Score of 2
2
votes
Accepted
How to programmatically create a file and write content using VS Code Extension API in TypeScript?
I'd stick with your current approach. Using vscode.workspace.fs.writeFile is better than the standard fs module because it handles VS Code's virtual file systems and updates the UI automatically.
...
Score of 2
2
votes
I'm getting the error The asset "./components/index.jsx.js" is not present in the asset pipeline
Because that's how it works. If the filename doesn't have a .js extension, Rails adds one. Your filename does not.
https://www.rubydoc.info/docs/rails/ActionView%2FHelpers%2FAssetTagHelper%...
Score of 0
0
votes
Switch without break in Javascript
This is by way of adding background.
A mercifully long time ago, you would control the flow of the program using something like a goto statement. You would typically test something and then possibly ...
Score of -1
-1
votes
how to reset <input type = "file"> in Angular
import { Component, signal } from '@angular/core';
@Component({
template: `
<input #fileInput type="file" (change)="updateFileName(fileInput)">
<h3>...
Score of 2
2
votes
Accepted
Full Calendar JS does not detect styles
As described in the FullCalendar Getting Started guide you need to choose a theme and a colour palette, and in your page you must reference the necessary files for your chosen options.
This will then ...
Score of 2
2
votes
Accepted
How to handle invalid date in Flatpickr
There are several issues
moment is deprecated
never alert in something that uses blur or similar
actually never alert at all
Make sure the DOM is ready when you add the event handlers
document....
Score of 2
2
votes
YouTube iframe always overlays the video for ~3 seconds before disappearing
Removing YouTube's iframe chrome by scaling the player, not the frame
Short version: YouTube's player chrome is sized in CSS pixels, and the video is
sized in percentages. So they do not scale ...
Score of 1
1
vote
How can I customize keyboard behaviour in HTML select menus?
Design ad hoc string comparer depending on locale
Define a helper function which depends on locale to compare the strings. For Swedish, A and Ä should be different.
For other languages such as English,...
Score of 0
0
votes
How can I move a <div> continuously at every given time-interval?
Maybe an idea to use a css animation?
@keyframes moveRight {
from { left: 0px }
50% { color: red; background: #FFFFC0; }
to { left: calc(100% - 100px); }
}
#a {
position: relative;
display: ...
Score of 1
1
vote
How can I move a <div> continuously at every given time-interval?
Avoid using margin to move stuff around, since it will cause layout thrashing / reflow, and margin has no support for GPU acceleration.
Use translate instead:
const myDiv = document.querySelector("#a")...
Score of 1
1
vote
How to query a custom element's internal elements while in the document from a DOMParser()?
I'm not sure that this is the best approach but the above mentioned question was answered by the original poster and still appears to work. See https://stackoverflow.com/a/46898817/9852762
It appears ...
Score of 2
2
votes
How to make an animated menu icon show/hide menu
So you want to open the menu when you click on the hamburger menu icon and close it when you click on the X icon. Also, when you click on the inner X icon you want to close the menu. At least this is ...
Score of 0
0
votes
Jest mock the same function twice with different arguments
You can use Jest's mockFn.mockImplementation(fn) (https://jestjs.io/docs/mock-function-api#mockfnmockimplementationfn).
You can do whatever you need to, read the incoming parameters and return ...
Score of 0
0
votes
How do i put a image (that isn't in the project page) on a canvas in Js?
Everything is Explained in the API
All you had to to is reading the API and using the method CanvasRenderingContext2D: drawImage().
Before you can do it, you can obtain the instance of ...
Score of 3
3
votes
How to interop with JavaScript DOM and handle static typing in Virune?
No, as far as I can tell from the docs, manipulating native JavaScript classes is against Virune's design philosophy, at least for version 1.0. Writing the JavaScript interopt in TypeScript, not ...
Score of 3
3
votes
YouTube iframe always overlays the video for ~3 seconds before disappearing
This is a very long and thorough question. I managed to get rid of everything except the pause icon. In your code I replaced:
.frame iframe { width:100%; height:100%; border:0; display:block; }
...
Score of 0
0
votes
iOS Safari/Chrome - Unwanted scrolling when focusing an input inside the modal
There are two different iOS scrolls that can look like the same bug here:
A gesture scroll falls through to the document because the modal's inner scroller has no scroll range.
Safari performs a ...
Score of 2
2
votes
How to make a button that switches between two colours?
You should never try to find a solution only to how it looks. HTML is all about semantics, which are lacking in the question and the answers so far.
Quality code separates concerns:
JavaScript and ...
Score of 1
1
vote
Avoid synthetic sounds overlapping
After some help, I found a solution that works:
<script>
const audioCtx = new AudioContext();
const oscillator = audioCtx.createOscillator();
function Freq(frq) {
...
Score of 0
0
votes
Best way to make part of a website editable for owner?
Rolling your own inline editor (contentEditable + a save endpoint) works, but in 2026 you'd usually reach for one of two things instead : the right one depends on how structured the content is.
Option ...
Score of 0
0
votes
Way to know if user clicked Cancel on a Javascript onbeforeunload Dialog?
Another possibility is to use a focus event and then start a timeout. The window gets a focus event after the user clicked anything on the dialog and the timeout gives the browser the time to do the ...
Score of -3
-3
votes
Webassembly, file input and virtual file system
These existing solutions are what you should do if you are required to use EDFLib, which is compiled via Emscripten.
For those arriving here through this question with the intent of merely reading EDF ...
Score of 0
0
votes
Calculate number images in a row to fit container while keeping aspect ratio
you should try group images into rows first before calculate the height
Keep adding images to the current row until adding the next image would make the row height fall below your desired minimum.
...
Top 50 recent answers are included
Related Tags
javascript × 2522053jquery × 585320
html × 500183
css × 220691
reactjs × 206035
node.js × 176323
php × 131474
angularjs × 119207
ajax × 102615
arrays × 92961
json × 78389
typescript × 63642
angular × 52725
vue.js × 45036
regex × 37433
asp.net × 34038
react-native × 33829
express × 33388
forms × 28855
c# × 28338
dom × 28017
google-chrome × 26794
object × 26754
twitter-bootstrap × 26653
d3.js × 26244