...

View Full Version : Mouseover Registering off Text



Evlich
01-05-2003, 03:33 AM
Ok, I am not sure if this should be here or in the xml forum, but take a look at teh problem. The page that I am refering to is located here:
http://webelements3.tripod.com/xElements/
Both the left menu and the right menu are implemented with the same css classes and all the functions are the same, but the right menu is generated using xml from an external file once the page is loaded. The discrepancy between the two menus is that the menu on the left will highlight the item even if you don't mouse over the text (if you put your cursor next to one of the Element words it will highlight it), but on the right menu you have to actually mouse over the TEXT. I want it like it is one the left menu. Is there a way to do this, or possibly something that I have overlooked? Thanks a lot. I appreciate your help.
~evlich

jkd
01-05-2003, 03:44 AM
Only see one menu in a post-Mozilla 1.3a build with GDI+ SVG rendering...

Evlich
01-05-2003, 03:58 AM
I forgot about that, I am still working on the non-IE xml parse. You will probably only be able to see it in IE.
~evlich

jkd
01-05-2003, 04:46 AM
Originally posted by Evlich
I forgot about that, I am still working on the non-IE xml parse. You will probably only be able to see it in IE.
~evlich

3 different ways of importing XML in IE and Moz:


function loadXML1(url, func) {
var request = new (window.ActiveXObject || XMLHttpRequest)('Msxml2.XMLHTTP');
request.open('GET', url);
request.onreadystatechange = function(evt) {
if (request.readyState == 4) func(window.event || evt, request.responseXML);
}
request.send(null);
}

function loadXML2(url, func) {
var doc;
if (typeof document.implementation != 'undefined' && document.implementation.hasFeature('Core', '2.0')) {
doc = document.implementation.createDocument('', '', null);
doc.onload = function(event) {
func(event, doc);
}
}
else if (typeof window.ActiveXObject != 'undefined') {
doc = new ActiveXObject('Microsoft.XMLDOM');
doc.onreadystatechange = function() {
if (doc.readyState == 4) func(window.event, doc);
}
}
doc.load(url);
}

function loadXML3(url, func) {
var doc = document.createElement('iframe');
var IEdone = false;
doc.style.display = 'none';
doc = document.body.appendChild(doc);
doc.onreadystatechange = function() {
if (doc.readyState == 'complete' && !IEdone) {
func(window.event, doc.contentWindow.document.XMLDocument);
document.body.removeChild(doc);
IEdone = true;
}
}
doc.onload = function(evt) {
func(evt, doc.contentDocument);
document.body.removeChild(doc);
}
doc.src = url;
}


second is probably best (has some W3C DOM standard code in it - document.load() however is still in WD in DOM3 L&S), but first is shortest and simplest.

Evlich
01-05-2003, 04:17 PM
Could you explain to me what the second parameter is? And does this parse the XML using an XSL style sheet?
The one that I have right now that works for IE is:


function loadXMLSource(xmlFile, xslFile, ele)
{
// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.load(xmlFile);

// Load XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM");
xsl.async = false;
xsl.load(xslFile);

// Transform
ele.innerHTML = xml.transformNode(xsl);
}

Thanks a lot.
~evlich

jkd
01-05-2003, 06:07 PM
Originally posted by Evlich
Could you explain to me what the second parameter is? And does this parse the XML using an XSL style sheet?

I prefer loading XML asynchronously so that it doesn't bog down the loading of the page, which is the the second argument is a reference to a function that is passed an event object, and the document object, after the file is done loading. Inside that function, you could apply XSLT transformations or whatnot.

Anyway, back to your original question? If you could link to the XSLT document you're using to transform into a menu, I think I might have an idea on what the problem is.

Evlich
01-05-2003, 08:20 PM
That is the XSL:
http://webelements3.tripod.com/xElements/xsl/leftmenu.xsl
~evlich

jkd
01-05-2003, 08:49 PM
I'm surprised this works at all. The XSLT document is invalid in several important ways:

1. It creates a fragment, not a wellformed document. XSLT can only generate well-formed XML, and in this case you don't have a document element.

2. It outputs markup, but it is not specified what kind. You should namespace it to XHTML, as well as set the output type to "HTML".

3. It is served as text/html! It *needs* to be served as text/xml, or application/xml

It may work in IE, but it would never work in any browser that conforms more so to the XSLT specification (like Mozilla).


Anyway, as for why IE is being stupid about the text, it shouldn't be. Try explicitly setting "width: 100%;" to the classes that apply to the generated markup, and see what happens.

Evlich
01-05-2003, 09:44 PM
I don't quite uunderstand what you mean. It is inserted into an html document, so wouldn't it inherit the<html> from the document it is inserted into? If not then do I have to do anything other than:


<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<xsl:apply-templates/>
</html>
</xsl:template>

I know that the acutual XML file is well-formed, it has a root called <leftmenu> but it doesn't really tanslate into anything because the styles are already done in the html file that it is imported into.

On the second note, I have only been working with xml for a little while, so how does the namespace thing work? Am I suppose to put <xhtml:div> or something or is that handeled in the <html xmlns="..."> thing?

And on the third thing that you mentioned. Isn't the output of the xsl actually xhtml, so shouldn't it be served as text/html?

Thanks a lot for all of your help.
~evlich

P.S. This topic should probably be moved to the XML forum.

jkd
01-05-2003, 11:59 PM
XSLT generates documents, not document fragments. I think this is where you've made your mistake.

I was saying that your result document is malformed. I didn't comment at all about the source document.

However, since you're not using the most correct of ways of importing the (malformed) result document into your current page, this works.

You don't want to output an entire HTML document in this script, you still just want the basic fragment. Wrap your output in a properly namespaced div:

<div xmlns="http://www.w3.org/1999/xhtml">
<xsl:apply-templates/>
</div>

And it suddenly becomes a well-formed document again (with correct namespaces).


As for the mime-type, is XSLT HTML? Of course not. Therefore, text/html is wrong. XSLT is XML, therefore text/xml is the proper way to serve it. Doesn't matter what the result document is.

Evlich
01-06-2003, 01:12 AM
This script eventually needs to be cross-browser, and I have a feeling that that means that I will need to get everything working to standards. How do I change the MIME type?
~evlich

jkd
01-06-2003, 02:10 AM
AddType text/xml xsl

into a .htaccess file on your server.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum