John Chacko. schrieb: > All, > I have 2 iframes in a page,(1). IFrameSVG & (2).IFrameHdn. > An asp page, whose Content-Type is image/svg-xml, is loaded in > IFrameSVG. And the SVG output is as expected. I have a global > javascript variable,ie GblVar, in svg. > > I want to know whether is it possible to change the GblVar from the > other iframe,ie,from my IFrameHdn. > > I think this question may be answered earlier... > But I find it difficult to search all mails in this group... > > > Can anybody help me....... > > > > thanks in advance,, > John Chacko > Hi John
inter document communication (idc) is currently a mess !!! there are some things you should know, for reliable idc you have to use the non-standart <embed>, because <object> is broken in InternetExplorer. the implementation of embed differs from browser to browser. the only plattforms where idc currently works, are IE + ASV3/6 and mozilla/firefox with native svg support. the <embed> tags important methods in this case are: getSVGDocument() //this works in mozSVG and IE+ASV getWindow() //IE only (if we could use <object> it would be: contentDocument and contentWindow ) so you could utilize getWindow() to solve your original problem. now you need access from the svgs to the parent html, this is where the next problem arises. usualy parent or window.parent should point to the parent html. but this does not work in some combinations of IE+ASV, you could use top instead of parent, which seems to be more robust than parent, but still breaks in some IE+ASV contexts. so from my point of view the most reliable way would be ( if possible) to move all code to the parent html. in that case, you would not need to talk to the parent html from svg, instead get a handle to the svg document, and then register event handlers from your html. this way, a global variable is atomaticly global to all your svgs. here is a small examle( that works reliable in mozSVG and IE+ASV): mainpage.htm: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>inter document communication</title> </head> <body onload="init()"> <embed type="image/svg+xml" src="rect.svg" style="display:block" width="300" alt="" align="left" title="simpleSVG" height="300"></embed> <embed type="image/svg+xml" src="circle.svg" style="display:block" width="300" alt="" align="left" title="simpleSVG" height="300"> </embed> <script> function init(){ e=document.embeds[0] //the first embedd ! sd=e.getSVGDocument() //the first embeds svg document rect=sd.getElementsByTagNameNS("http://www.w3.org/2000/svg","rect").item(0) //get the rect element rect.addEventListener("mouseover",over,false) rect.addEventListener("mouseout",out,false) rect.addEventListener("click",changeCircleColor,false) e=document.embeds[1] sd=e.getSVGDocument() circle=sd.getElementsByTagNameNS("http://www.w3.org/2000/svg","circle").item(0) circle.addEventListener("mouseover",over,false) circle.addEventListener("mouseout",out,false) } function over(evt){ evt.target.setAttribute("fill",circle.getAttribute("fill")) } function out(evt){ evt.target.setAttribute("fill","blue") } function changeCircleColor(){ var r=Math.floor(Math.random()*255) var g=Math.floor(Math.random()*255) var b=Math.floor(Math.random()*255) circle.setAttribute("fill","rgb("+r+","+g+","+b+")") } </script> </body> </html> rect.svg: <?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 600 600" > <rect x="100" y="100" width="400" height="400" rx="100" ry="100" fill="blue"/> </svg> circle.svg: <?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 600 600" > <circle cx="300" cy="300" r="200" fill="blue"/> </svg> p.s.: please do not use the old mime type for svg, insted use image/svg+xml (with a plus not a minus)!! p.p.s.: i would not use iframe, because im IE if you use iframe, an implicit html document will be created for each svg , which holds an embedd, wich in turn holds the reference to your svg, in mozilla however, there is no implicit html document. so this is even more complicating things. hope that helps Holger ----- To unsubscribe send a message to: [EMAIL PROTECTED] -or- visit http://groups.yahoo.com/group/svg-developers and click "edit my membership" ---- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/svg-developers/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/