Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interacting with Frames

Status
Not open for further replies.

victorsk

Programmer
Jul 26, 2005
21
CA
Hello,

I was wondering how to make two frames interact with eachother. What I have is an SVG code in both files and I need to make one file trigger response in another. I know it has something to do with:
var svgobj = parent.my_svg_frame.document.getElementByID(element); then use
svgobj.getStyle().setProperty('display', 'inline');

but I keep getting "error parent.my_svg_frame is null or not an object" error. This approach works within a single file when trying to trigger elements (press a button and image appears) but it is necessary that I use separate files for that any ideas?

Please help,
Thank you,
Victor.
 
I assume 'my_svg_frame' is the ID of the frame you're targeting and that you have the case correct?
 
Hi,

Well, no, that was just an example. Here is the actual code:
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN"
"<head xmlns=" xml:lang="en" >
<title>Northeast States - An SVG Example</title>
<script type="text/javascript">
function hilite_elem(checkbox, element_name)
{
// For each element, get the element's style object, then set
// its visibility according to the state of the checkbox.
var svgobj = parent.mainFrame.document.embeds['printable_map'].getSVGDocument().getElementById(element_name);
if (!checkbox.checked){
// Hide layer.
svgobj.getStyle().setProperty('display','none');
} else {
// Show layer.
svgobj.getStyle().setProperty('display','inline');
}
}
</script>
</head>

//At this point I am trying to make a button and then use the above script to invoke properties of a different frame

<body>
<div id="content"><div id="page">
<p class="first">
<div id="map">
<div id="map-window">
</div>
<div id="map-legend">
<form name="hilite_form" action="">
<p class="title">Layer Visibility</p>
<svg>
<g>
<rect width="15" height="10" x="0" y="20" style="stroke:black;stroke-width:1;fill:rgb(255,0,255);" onmousedown='hilite_elem("NE_InterstateHwy")' >
</rect>
<text x="20" y="254" style="font-size:18;">
TAR1_2_CLAIMS
</text>
</g>
</svg>
</form>
</div>
</div>
</p>
<h2>&nbsp;</h2>
</div>
</div>
</body>
</html>
 
Sorry, one more thing, please ignore the way I am calling that function, my problem is inside the script with trying to create an svgobj object.

Thank you,
Victor.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top