Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get VML working in standards mode?

I would like to be able to use vml objects on a page rendering in standards mode rather than quirks mode. I've found fragments of answers scattered around but can't figure it out. Raphael pulls it off somehow but I can't reverse it to figure out what's happening. Any basic working example would be great.

like image 320
lincolnk Avatar asked Oct 07 '10 19:10

lincolnk


People also ask

How do I use VML in HTML?

To use VML in your web pages, use a style element to import the VML behavior, as shown in the following code. Next, declare the VML namespace, as shown in the following code sample. Finally, add VML elements to define visuals effects.

Why do I need DOCTYPE to use standards mode?

If you serve XHTML-like content using the text/html MIME type, browsers will read it as HTML, and you will need the DOCTYPE to use standards mode. How do I see which mode is used?

What happened to VML in Internet Explorer?

This topic describes VML, a feature that is deprecated as of Windows Internet Explorer 9. Webpages and applications that rely on VML should be migrated to SVG or other widely supported standards. As of December 2011, this topic has been archived. As a result, it is no longer actively maintained.

What is the purpose of MVVM pattern?

The obvious purpose of MVVM pattern is abstraction of the View which reduces the amount of business logic in code-behind. However, following are some other solid advantages − The ViewModel is easier to unit test than code-behind or event-driven code. You can test it without awkward UI automation and interaction.


1 Answers

I think I have it figured out. Step 1 is importing the vml namespace though javascript.

document.namespaces.add('v', 'urn:schemas-microsoft-com:vml', "#default#VML");

This got some random vml samples to work in quirks mode but not standards. They key is that elements require a unit for measurements where quirks mode will assume px if a unit is not provided. Also shapes have to be styled with position:absolute; although lines apparently do not need this part.

Here's a sample with 2 ovals. Both ovals will render in quirks mode but the blue oval will not show in standards mode.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
    <script>
        document.namespaces.add('v', 'urn:schemas-microsoft-com:vml', "#default#VML");
    </script>
    <v:oval style="width: 100; height: 50" fillcolor="blue"></v:oval>
    <v:oval style="position: absolute; width: 100px; height: 50px" fillcolor="green"></v:oval>
</body>
</html>
like image 139
lincolnk Avatar answered Nov 10 '22 01:11

lincolnk