473,387 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

SVG doesn't raise events when embedded in HTML

Hi,

I am new to web technologies, including HTML, SVG and javascript. I
followed the courses for these languages on www.w3schools.com. I have
a question about events raised by a SVG document. The SVG is embedded
in an HTML source.

I made a simple SVG file that contains a red circle with a black
outline. I also wrote a javascript that turns the outline color red.
The function is called by the onmouseover event from the circle. It
all works properly when I open the SVG seperately in IE5. However,
when I embed the SVG file in an HTML file it doesn't work properly
anymore. I open the HTML in IE5, the SVG is showed, but it doesn't
respond to events.

These are the sources I wrote:
HTML (main.html):
<HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<BODY>
<object data="Circle1.svg" width="300" height="300"
type="image/svg+xml">
<embed src="Circle1.svg" width="300" height="300"
type="image/svg+xml" />

</object>
</BODY>

</HTML>
-----------------------------------------------------------------------

SVG (Circle1.svg):
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg width="300" height="300">
<script xlink:href="Circle1Script.js" type="text/javascript" />

<circle id="circle" cx="100" cy="50" r="40" stroke="black"
stroke-width="8" fill="red" onmouseover="ChangeColor(evt)"/>
</svg>
-----------------------------------------------------------------------

JavaScript (Circle1Script.js):
var svgDoc;
var svgObjCircle;
function initsvg(evt){

var directTarget = evt.getTarget();
if( directTarget.getNodeType() != 9 ) // if not DOCUMENT_NODE
{
svgDoc = directTarget.getOwnerDocument();
}
else
{
svgDoc = directTarget;
}
svgObjCircle = svgDoc.getElementById("circle");
}

function ChangeColor(evt) {
var SVGDoc=evt.getTarget().getOwnerDocument();
svgObjCircle=SVGDoc.getElementById("circle");

svgObjCircle.setAttributeNS(null, "stroke", "red");
}
-----------------------------------------------------------------------

Does anyone know how to solve this problem?
Jul 20 '05 #1
0 1758

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: askingBoy | last post by:
Hello , I would like to know how to make this : I have a library written in Visual Basic .Net that has some events for its class , I am making an instance of this class in a Visual basic 6.0...
2
by: Andrew | last post by:
Hi, friends, I need to raise certain events in my VC# windows control library. Any reference paper or sample source code for help? Thanks a lot...
5
by: Mark Overstreet | last post by:
I am writing an app that needs to contain an object model that allows it to be controlled similiar to something like Word. However, I am writing this in C# and all managed code. I know that I can...
4
by: Jeremy | last post by:
I have a combobox with a SelectionChangeCommitted event handler, and am having a problem raising this event. For example, raiseEvent mycombobox.SelectionChangeCommitted gives me an error...
1
by: Rethish R | last post by:
Hi, I have defined few Events in VB.Net, Register the DLL using "Register Interop for COM" Option. Now I have referred the class in VB 6.0. That is add the referrence for the DLL. But I am not...
1
by: Anonieko | last post by:
I know Visual Studio lacked support on easily writing code to raise events from a ascx user control ( because you have to hand write them)....
4
by: Venkatesh | last post by:
Hello All, I have an iframe in my main html and within iframe, I'm loading another HTML webpage. In my main html page, I've captured the mouse click event, by setting the "onclick" for <bodyof...
2
by: Num GG | last post by:
Hi all, Given this simple code: <div id="mydiv" ondblclick="alert(id)" //parent div Div4 bla bla bla bla on div 4 <div id="myembeddeddiv"ondblclick="alert(id)" // child div...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.