I have a complex Jquery-UI based dialog and I want to provide a SVG image as background. I tried to make this work in a simple test file first and it does not work though the SVG, as a standalone image, works fine. Here is the simplified code:
 <script>
 $(document).ready(function () { 
  svg = "<svg width='400' height='400' fill='url(#grad1)'  \
   xmlns='http://www.w3.org/2000/svg'> <rect id='bkgrect' width='400' \
   height='400' style='fill:'url(#grad1)'; stroke-width:3;'/> <defs>\
   <linearGradient id='grad1' x1='0' y1='20%' x2='0%' y2='100%'> \
   <stop id='stop1' offset='0%' stop-color='blue'/> <stop offset='100%' \
   stop-color='white'/> </linearGradient> </defs> </svg>";
  svgBase64 = btoa(svg);
  bkgrndImg = "url('data:image/svg+xml;base64,"+ svgBase64  +"')";
  $('#testDiv').css('background-image', bkgrndImg);
 });
</script>
</head>
<body>
  <div id='testDiv' style="border:2px solid red;width:400px;height:400px;
     position:absolute;left:100px;top:100px;"> Some SVG Div </div>
  <svg ... /svg>
The svg ... /svg is the same svg as used in the background and it displays properly.
After looking at various solutions, I have relied primarily on this post. I also tried to simulate background SVG image by using z-index and positioning the image in the Div as an image but thats not a good fix. I want to get SVG as a background image to work smoothly across browsers because at least SVG gradients are well supported in all modern browsers and I think the time for SVG's potential to be fully realized has finally arrived.
 
     
     
     
    