Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8452667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:33:31+00:00 2026-06-10T11:33:31+00:00

I have a portion of JavaScript in an HTML page that says: function flashElements()

  • 0

I have a portion of JavaScript in an HTML page that says:

function flashElements() {
    var svg = document.getElementById("mysvg").getSVGDocument();
    var all = svg.getElementsByTagName("flash");
    for (var i=0, max=all.length; i < max; i++) {
        if (all[i].flash === "on")
        {
            all[i].setAttributeNS(null, "fill", "lime");
        }
    }
}

with the SVG loaded as follows:

<object data="alpha.svg" type="image/svg+xml" id="mysvg" width="800" height="600"></object>

The idea is to call this on a particular trigger and, if any SVG elements have the particular attribute of “flash” then their fill attribute will change colour. Of course, the above doesn’t work – it’s looking for elements, not attributes. So how do I iterate through all the SVG elements, looking for anything with that particular attribute?

The SVG has:

<polygon points="203,20 209,32 205,32 203,28" class="trackPlain" flash="on" />
<polygon points="205,32 209,32 217,48 213,48" class="trackPlain" flash="off" />

Actually all I want to do is flash the elements (on/off) but of course IE doesn’t support animations.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:33:32+00:00Added an answer on June 10, 2026 at 11:33 am

    Not very efficient, but I imagine you could do something like this:

    var allElements = svg.getElementsByTagName("*");
    for(var i = 0; i < allElements.length; i++) {
        var element = allElements[i];
    
        if(element.getAttribute("myAttr") === "on") {
            element.setAttribute("fill", "lime");
        }    
    }
    

    Your other option is to do a tree-traversal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an html page i want to print a portion of this html
I have a script which loads content into a iframe using: document.GetElementById('iframeid').src = 'site.html';
I'm dealing with jquery selector. I have a portion of html that (simplified) looks
Let's say I have this portion of HTML document: <div>hello world <span id=test></span></div> In
The problem: we have one application that has a portion which is used by
I am building a site that will (obvisouly) have a front end public portion
I have implemented an XMLHttpRequest() call to a standalone html page which simply has
I'm working on a javascript function that when called will make a ajax request
I'd like to have a group of HTML text <input> 's that can be
I am attempting to have a file upload page that allows for an arbitrary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.