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 8 of 8
  1. #1
    Regular Coder
    Join Date
    Mar 2009
    Location
    Germany
    Posts
    101
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Question ONMOUSEUP probs in FF

    Hi folks,
    especially Venegal !!
    TWO PROBLEMS:

    I have come up with a problem regarding the onMouseUp in IE and FF.
    Basicaly the problem is self explanatory if you take a look at this site : http://www.nigels.de/fia.html in both browser.

    in FF it doesn't work, is there a way round this, it also has to be compatible with the following script:
    if you can fix this for me first, I'll come to the second Problem which is somewhat more complicated.
    Code:
    function toggle(id, status){
    	document.getElementById(id).style.visibility = status;
    }
    
    function populateSearchField(){
    	var specialChars = "\\.+*?[^]$(){}=!<>|:,-=/";
    	var ignoreList = ["a", "the"];
    
    	var i, j, searchFld, keywords;
    	if (!(searchFld = document.getElementsByName('formcontent')[0])) return;
    	if (!(keywords = document.referrer.match(/[pq]=(.*?)&/))) return;
    	var preg_quote = function(str){return (str+'').replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!<>\|\:])/g, "\\$1");}
    	keywords = decodeURIComponent(keywords[1]).replace(new RegExp('[' + preg_quote(specialChars) + ']', 'g'), ' ').split(/[\+ ]/);
    	for (i = 0; i < keywords.length; i++){
    		for (j = 0; j < ignoreList.length; j++) if (!keywords[i] || (keywords[i] == ignoreList[j])) {
    			keywords.splice(i--, 1);
    			break;
    		}
    	}
    	searchFld.value = keywords.join(' ');
    }
    
    function keywordMatch(keywords, text) {
    	var result = 0;
    	for (var i in keywords) {
    		if (text.match(new RegExp("(^| )" + keywords[i] + "( |$)", "i"))) {
    			result++;
    		};
    	}
    	return result;
    }
    
    function showTextContent() { 
    	var i, bestMatch, maxNumberOfMatches = 0;
    	var divs = document.getElementById("ts-1").getElementsByTagName('div');
    	var keywords = document.getElementsByName('formcontent')[0].value.split(' ');
    	for (i = 0; i < divs.length; i++) {
    		var div = divs[i];
    		var divcontent = div.lastChild.nodeValue;
    		if ((numberOfMatches = keywordMatch(keywords, divcontent)) > maxNumberOfMatches) {
    			maxNumberOfMatches = numberOfMatches;
    			bestMatch = div;
    		}
    	}
    	if (bestMatch) 
    		bestMatch.onmouseover();
    	else {
    		alert("no match");
    	}
    }
    window.onload = function(){
    populateSearchField();
    showTextContent();
    }
    Thx

  • #2
    Regular Coder
    Join Date
    Mar 2009
    Location
    Germany
    Posts
    101
    Thanks
    10
    Thanked 0 Times in 0 Posts
    no help today?

  • #3
    Regular Coder
    Join Date
    Mar 2009
    Location
    Germany
    Posts
    101
    Thanks
    10
    Thanked 0 Times in 0 Posts
    is nobody able to help me or do you simply not want to?

    the actual div where I need the onmouseup is this:
    Code:
    <div  class="ts-1-B" showTextContent();toggle('fo-test1', 'visible');"><object type="application/x-shockwave-flash" data="p101b.swf" width="358" height="296"><param name="movie" value="p101b.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="false" /></object><br />.</div>
    				<div  onmouseover="this.className='ts-1-1over'; toggle('fo-test1', 'visible');" onmouseout="this.className='ts-1-1';showTextContent();toggle('fo-test1', 'hidden');" onMouseUp="this.className='ts-1-B';" class="ts-1-1"><object id="fo-test1" style="visibility:hidden"  type="application/x-shockwave-flash" data="p101a.swf" width="358" height="258"><param name="movie" value="p101a.swf" /><param name="quality" value="high" /><param name="wmode" value="opaque" /><param name="menu" value="false" /></object>USA</div>

    the Flash file takes the priority with an intregrated onpress(), so this is why I need the onmouseup over the area to direct the flash to anothe div

    I have found this script:

    <script type="text/javascript">
    document.body.onmouseup = mouseup;
    document.getElemensById("bbbb").onmousedown = mousedown;

    function mouseup() {

    }

    function mousedown() {}


    but I have know idea whether the script above will help me, as I don't know how to intergrate in the html.
    the problem is that time is against me, so I am not able to start from the basics of JS.

    Please be so kind and help me someone.
    thx
    Last edited by dododidi; 06-18-2009 at 03:16 PM.

  • #4
    Gütkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Alright, I don't have much time right now, but I gave it a quick glance, and the problem appears to be the following:

    When the onmouseup event is triggered, you change the className to "ts-1-B", which effectively moves the div the a position where the mouse pointer isn't hovering over it anymore. This triggers the onmouseout event, which changes the className back to "ts-1-1" and thus moves the div back to its original position, which causes the onmouseover to be triggered, which, as the final step in this mess of a logical flow, sets the className back to "ts-1-1over", and it appears as if nothing had happened.

    The reason it looks like it's working in IE is because of a bug (or maybe it's by design, who knows) that causes onmouseout and onmouseover events to only be triggered when there has been actual mouse movement. My strong suggestion is designing for standard compliant browsers and not caring about IE until a later stage. Getting something to work in IE, but not anywhere else, is nothing but lost time.

    Now, I don't really have time at the moment to care about what exactly it was you were trying to accomplish, but I hope my analysis of the actual situation helps you fix the problem.

    Something that might get you started: You say you want the large div to change when the mouse is released over the small div. Why do you use 'this.className' in the onmouseout of the small div then, when 'this' refers to the small div and you really want to change the large one?

  • #5
    Regular Coder
    Join Date
    Mar 2009
    Location
    Germany
    Posts
    101
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Something that might get you started: You say you want the large div to change when the mouse is released over the small div. Why do you use 'this.className' in the onmouseout of the small div then, when 'this' refers to the small div and you really want to change the large one?
    Quite simple the answere to that:
    when mouseover small divs, a loading/play funtion is called from the flash(visible only on the small divs)and since there are no spaces between the divs the mouseout closes the small div and automatically opens the next small div, which in turn on mouseup redirects to the larger div.

    UPDATE NOTE:
    I am not trying to get it working only in IE, but all browsers, the original site is W3c conform, the prob is that the mouseup will not work in FF
    Last edited by dododidi; 06-18-2009 at 05:16 PM.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,664
    Thanks
    80
    Thanked 4,643 Times in 4,605 Posts
    Looks to me like Venegal's analysis is 100% correct.

    You are relying on a *BUG* in MSIE to get it to work.

    I think one way you could fix it would be to put the "Play" image inside of an extra <DIV> and, when you move the "Play", leave the <DIV> where it is. The put the mouse events on this new extra <DIV>. Since it won't move, you won't have the problem Venegal noted.

    But I agree completely with him here: Forget whether it works in MSIE or not, since the only reason it is working there is because of a bug.

  • #7
    Regular Coder
    Join Date
    Mar 2009
    Location
    Germany
    Posts
    101
    Thanks
    10
    Thanked 0 Times in 0 Posts
    thx , I'll try the work arround, damm it, they flew to the moon with a C64 but they can't do an onmouseup

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,664
    Thanks
    80
    Thanked 4,643 Times in 4,605 Posts
    LOL!!!!

    Now, let's be fair! A C64 had much more memory than the computer they used to fly to the moon! And the C64 had a disk drive, too!

    If you can't get it, post again. There *has* to be a way to make it work.


  •  

    Posting Permissions

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