JavaScript causing inconsistencies in SVG filter updates across different browsers

Looking for a way to adjust the filter of an svg object using javascript, specifically changing a grey shadow to red upon mouseover.

The issue is that in Chrome and Safari, the desired effect does not occur, while Firefox functions as intended. When using the Javascript debugger, Safari responded correctly, which raises concerns about potential timing issues with the webkit that are beyond my control.

Ultimately, I aim to discover a solution that enables a filter update via javascript across all three browsers: Safari 11.1, Chrome 65.0.3325.181, and Firefox 59.0.2

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<svg width="250" height="150">
    <defs>
        <filter id=glow x="-50%" y="-50%" width="200%" height="200%">
            <feDropShadow dx=2 dy=2 stdDeviation=2 flood-color="#F00" />
        </filter>
        <filter id=shadow x="-50%" y="-50%" width="200%" height="200%">
            <feDropShadow dx=2 dy=2 stdDeviation=2 flood-color="#888" />
        </filter>
    </defs>
    <g style="filter: url(#shadow)">
        <rect x=50 y=50 width=50 height=50 style="fill: yellow"
            onmouseover="this.parentNode.style.filter = 'url(#glow)'"
            onmouseout="this.parentNode.style.filter = 'url(#shadow)'" />
    </g>
    <g style="filter: url(#shadow)">
        <rect x=150 y=50 width=50 height=50 style="fill: green"
            onmouseover="this.parentNode.style.filter = 'url(#glow)'"
            onmouseout="this.parentNode.style.filter = 'url(#shadow)'" />
    </g>
</svg>
</body>
</html>

Link to Codepen: https://codepen.io/anon/pen/yjeXMJ?editors=1000

Answer №1

By eliminating the .parent selector:

onmouseover="this.style.filter = 'url(#glow)'"

The functionality is successfully implemented in Chrome. I trust this information will be beneficial.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Submitting with enter key on typeahead suggestions

Seeking guidance on Bootstrap typeahead: how can I configure it to submit the entered text upon pressing the enter key? Specifically, if I type "hello" in the typeahead input and hit enter, how can I submit "hello"? I've successfully disabled the aut ...

What is the proper way to include a closing tag for the canvas in a Canvas rendered by Three.js

Why does three js always add canvas elements without a closing tag to the page? Is there a specific reason for this? I'm interested in adding a closing tag to this canvas element. This example page was inspected, revealing something similar to this ...

Alter the font color upon clicking the menu using jQuery

When I click on the menu and sub-menu items, I want to change their colors along with their parent. You can see an example of how I want it to work here. However, currently, when I click on a sub-menu item, the color of the parent menu item gets removed. ...

Explore the possibilities with Intel XDK's customizable keyboard feature

I recently started using Intel XDK for development and I encountered the following issue: I have an input text field (HTML) and I need to restrict user input to only numbers, decimals, and negative sign when they click on the field. How can I achieve this ...

After repeated attempts to initialize and destroy, Froala encounters issues when loading a textarea via Ajax

Whenever an EDIT button is clicked to update some Blog Data, it triggers an Ajax call that brings up a textarea for Froala and initiates the initialization process. This sequence works smoothly initially, but after a few cycles of edit/submit (1, 2, or 3 o ...

Losing authentication token when refreshing with Nuxt asyncData and Axios

While testing a get API that retrieves an array of mail data through Postman, everything seems to be working smoothly. However, when I implement the asyncData method to fetch the array in my code, it only works once. Upon page refresh, I encounter a 401 er ...

Establishing properties while creating a fresh instance of a class

I am currently working on developing an invoice application using TypeScript. In my project, I have created an Invoice class with several properties and objects. However, when attempting to set the properties of an item object within the Invoice class usin ...

Traversing a JavaScript array with multiple dimensions containing markers created with Google Maps APIs

I have a single array where I store all of the Google Maps marker objects. Currently, I am working on creating a function to remove all markers from the map that are in the array, but I'm facing issues with the loop. First, I add each marker to the a ...

Can anyone provide guidance on how to simulate a click on a JavaScript action for an iPhone?

I am attempting to trigger a click on a "javascript:void(0)" link so that I can retrieve HTML data within the script. Can someone advise me on how to achieve this without using illegal APIs like UITouchEvent, as I only work with NSUrl? Thank you in advan ...

Visual elements failing to load in canvas due to fs/nodejs integration

I've been working with nodesjs and fs to set up a server that can render an HTML page. The HTML page includes a script written in JavaScript to create a canvas, load an image, and draw the image on the canvas. I've run into an issue where when I ...

Achievement with ajax: If the status code is 200, execute one function; otherwise, execute a

I can't figure out why this isn't working... I'm using $.ajax to run file.php and pass a POST value from an input field. Even though the file.php is functioning properly (it successfully adds a user to my newsletter), my ajax function seems ...

An unassigned variable automatically sets the disabled attribute to true on an input field

Is this behavior a problem or normal? Consider the following form structure: <form #form="ngForm" > <div> <label>field1</label> <input type="text" name="field1" [(ngModel)]="mainVar" [disabled]="someVar" /> ...

Incorporate a React web application seamlessly into a React Native WebView component

In my monorepo, I have a web app and a mobile app (built with React and React Native respectively). My goal is to embed the web app into the mobile app using React Native WebView. After reading the documentation, I learned that the source for the WebView ...

Looking to add a dynamic drop-down menu to my search bar, similar to Google search

Is there a way to create a dynamic drop-down list where, when a user enters the first letter of a country name, the list displays countries with names starting with that letter? It's similar to the functionality of a Google search bar. The country nam ...

Guide to displaying a particular item in Vue 3

Currently, I am embarking on a project that requires the functionality to print a specific element of my webpage. After some research, I came across a mixin/plugin known as VueHtmlToPaper which seems to be the perfect solution for what I need. However, I a ...

Animating Text Changes with JavaScript and jQuery

In my HTML, I have an input type="text" element and I want to attach an event handler that triggers when the text is changed. The issue arises because this input's value is dynamically updated by another JavaScript function, causing the event handler ...

Using Javascript to dynamically flash-highlight text on a webpage when it first loads

I am looking to create a special highlight effect that activates when the page loads on specific text. Let's focus on the element with id="highlight me". The highlight should glow twice around the selected container before fading out. For a clear unde ...

How can I remove the focus highlight from the MUI DatePicker while retaining it for the TextField?

I am currently working on developing a date picker using react.js with the MUI DatePicker library. The code I have implemented closely resembles what is provided in their documentation. However, upon rendering the component, I am encountering an issue whe ...

Maintaining personalized variable values for individual connected clients in Node.js: What's the best approach?

I have recently started working with Node.js and I am using Visual Studio 2015 with the Basic Node.js Express 4 app template. After setting some values through a post request from the client, I noticed that when I open another tab and send another post re ...

ERROR TRACKER: Unable to locate file "CL.exe". File not found in system

I am attempting to run the following command in a Node.js project on my Windows 8 machine: npm install [email protected] However, I am encountering an error that I am not sure how to resolve. TRACKER : error TRK0005: Failed to locate: "CL.exe". ...