Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Mouseover Registering off Text

    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

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Only see one menu in a post-Mozilla 1.3a build with GDI+ SVG rendering...

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    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:
    Code:
    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.
    Last edited by jkd; 01-05-2003 at 05:50 AM.

  • #5
    New Coder
    Join Date
    Jun 2002
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:
    Code:
    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

  • #6
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    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.

  • #7
    New Coder
    Join Date
    Jun 2002
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #8
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    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.

  • #9
    New Coder
    Join Date
    Jun 2002
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:
    Code:
    <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.

  • #10
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    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.

  • #11
    New Coder
    Join Date
    Jun 2002
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #12
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    AddType text/xml xsl

    into a .htaccess file on your server.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •