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 9145781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:35:57+00:00 2026-06-17T10:35:57+00:00

I want to access VML element which stores fill image in VML. I pasted

  • 0

I want to access VML element which stores fill image in VML. I pasted my demo code below. Notice that it will only work when you include raphael.js and jquery.js.

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta charset="utf-8">
        <title>Raphael Test</title>

        <script type="text/javascript" src="js/libs/jquery.js"></script>
        <script type="text/javascript" src="js/libs/raphael.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {

                var raphael, path, pattern;

                raphael = Raphael(document.getElementById('raphael'), 500, 500);

                path = raphael.circle(100, 100, 80);
                path.attr('stroke-width', 3);
                path.attr('fill', 'url(http://3.bp.blogspot.com/_M4WdA9j-b-g/TLMF9JJJwcI/AAAAAAAAAV4/p0Y_Wo3S3sQ/s1600/Landscape1.jpg)');
                pattern = $(path.node).attr('fill');
                if(pattern) {
                    pattern = pattern.replace('url(', '').replace(')', '');
                    pattern = $(pattern);
                }

                // Shape element documentation: http://msdn.microsoft.com/en-us/library/hh846327(v=vs.85).aspx#shape_element
                // Fill element documentation: http://msdn.microsoft.com/en-us/library/bb229596(v=vs.85).aspx

                if(Raphael.vml) { // SVG not supported (IE7 & IE8) and it doesn't work :/
                    console.log($(path.node).find('fill').attr('href'));
                }
                else { // SVG supported and it prints correct URL
                    console.log($(pattern).find('image').attr('href'));
                }
            });
        </script>

    </head>
    <body>
        <div id="raphael"></div>
    </body>
</html>

In SVG fill image is provided using pattern element. That’s why I’m fetching this element, and I can easily access its href attribute.

VML is pretty different. Path is created with shape element, which have fill element inside. But unfortunately fill element doesn’t have any attributes:/

Can someone help me to access VML fill image element?

  • 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-17T10:35:58+00:00Added an answer on June 17, 2026 at 10:35 am

    I found the solution. I edited part of code above:

    if(Raphael.vml) { // SVG not supported (IE7 & IE8) and it doesn't work :/
    
        var html = $(path.node).html();
        html = html.replace(/rvml:/g, ''); // remove prefix
        html = html.replace(/ = /g, '=');
        html = html.substr(html.indexOf('/>') + 2); // remove xml element
    
        var src = '';
        $(html).each(function() {
            if($(this).prop("tagName") == 'FILL') {
                src = $(this).attr('src');
            }
        });
    
        if(src != '') {
            var html = $(path.node).html();
            html = html.replace(src, src + '" size="50,50');
            $(path.node).html(html);
        }
    }
    else { // SVG supported and it prints correct URL
        console.log($(pattern).find('image').attr('href'));
    }
    

    First of all $(path.node).html() returns XML… So you need to parse it.

    Another problem is that $.parseXML doesn’t work for this XML… (IE7 and IE8) So I had to somehow parse it for myself (it’s just quick solution – I’m sure you can parse it much better for production).

    Last thing is that $(html) returns array of 6 elements (not 3!) because for some reason it treats closing tags separately. That’s why I’m looping through $(html) set of elements and I’m searching for fill tag.

    Biggest problem of this approach is that my solution is read only. You can’t change source of the image and easily save it back… You cant easily change its size as well. You will have to change it in XML and save it back to path element, as it’s on the end of example.

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

Sidebar

Related Questions

I want to access the following path on Ubuntu in my python code: ~/.mozilla/firefox/dh4ytbdj.default/bookmarkbackups
I want to access java script's return value , which in is in a
I want to access the session variable which I declared in the another php
I wrote the code below in order to manipulate the color of an image.
I want access to a picture using image.setImageResource(R.drawable.photo1); How can I change photo1 to
i have bean that contain method [void return] and want access to this bean
I want to access a specific element using xpath.This is my the result of
I want to access a certain address of a process. But for that i
i want to access AmenityCodes you can see in the image for 0 position
I want to access camera to record video to upload, but have come across

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.