From: Richard B. <ric...@sk...> - 2001-07-12 22:55:32
|
Yes, the NS changes would seem a good idea. I noticed that what I had suggested for IE was working by accident, I had expected e.returnValue to return the return value, but it doesn't, it returns undefined, which was being evaluated as false. The only way I found of retrieving the return value in IE was this: if(e.srcElement.attributes['on'+e.type].nodeValue.indexOf('return false')!=-1) which would return false if value = return false. I tried, but couldn't find how to get this value in Mozilla yet. Maybe I'm missing something obvious, as I hadn't expected it to be so hard to get hold of that value. I also added this: && e.type!='mousemove' to the first if clause, for both IE and NS, otherwise the script is being executed constantly as the mouse moves over the page, or a link, and onmousemove never needs a return event that I know. Also without this check, NS4 started selecting text on the page while dragging a dynlayer. So now the whole thing looks like this: mouse.js from line 146: // Click on links and form elements if(e && e.target.handleEvent && e.target!=this&& e.type!='mousemove'){ evt.browserReturn = (e.target.handleEvent(e)==false)?false:evt.browserReturn; } }else if(is.ie&&e&&e.srcElement!=this&&e.type!='mousemove'&&e.srcElement.attribute s['on'+e.type].nodeValue){ evt.browserReturn = (e.srcElement.attributes['on'+e.type].nodeValue.indexOf('return false')!=-1)?false:evt.browserReturn; } return evt.browserReturn; } (mind line wraps) Like this, "return false" in the onclick listener of a hyperlink will cancel browser navigation, as it should. This works in IE and NS. I don't know if something simpler is possible for IE, and I haven't found the values for Mozila yet. Cheers, Richard Bennett ma...@ri... www.richardinfo.com (Everything running on, and ported to DynAPI2.53) visit the DynAPI homepage (and FAQ) :: http://dynapi.sourceforge.net/dynapi/index.php?menu=1 Browse (and search) the mailinglist here: http://www.mail-archive.com/index.php3?hunt=dynapi ----- Original Message ----- From: "Joachim Lundgren" <lu...@ho...> To: <dyn...@li...> Sent: 12 July, 2001 01:57 Subject: Re: [Dynapi-Help] NS4 link/event cancelling [Was: (no subject)] > At 2001-07-12 00:13, you wrote: > >Well it looks like your right, but there are a few issues, firstly, this is > >only for NS4, the other browser code seems to be missing all together. > >I think the whole thing, crossbrowser should look like this: > > > >This replaces the line nr 147 in mouse.js: > > > > > > > > // Click on links and form elements > > if (e && e.target.handleEvent && e.target!=this)evt.browserReturn = > >e.target.handleEvent(e); > > }else{ > > if(e&&e.srcElement!=this)evt.browserReturn =e.returnValue > > > > > > > >The closing bracket is already in the code. > >I tested this, and it solves the problem in IE5.5, Mozilla, and NS4. > > > >It does however cause NS4 to fire two onclick events over a regular > >dynlayer, I think this might be something Jordi could solve easily (?) > > > >Cheers, > >Richard Bennett > > > For some reason I thought the problem only appeared in NS4... > > Now that this is being considered for inclusion in the codebase I suggest that the end of that function to be (indented so it looks better in email): > > // Click on links and form elements > if(e && e.target.handleEvent && e.target!=this) { > evt.browserReturn = (e.target.handleEvent(e) == false) > ? false > : evt.browserReturn; > } > } > else { > if(e && e.srcElement!=this) > evt.browserReturn = e.returnValue; > } > > return evt.browserReturn; > } > > The reason would be to allow the (in this case) onclick-handler to cancel the click with a "return false". If it instead returned "true" or nothing at all it should respect the evt.browserReturn value which is true by default unless changed by evt.cancelBrowserEvent(). > > This is, of course, untested. Haven't even checked what should be done in IE/Mozilla. > > /Lunna > > > _______________________________________________ > Dynapi-Help mailing list > Dyn...@li... > http://lists.sourceforge.net/lists/listinfo/dynapi-help > |