Followup... (all questions appear in red)
This posted code works well and I like the simplicity with setting a boolean value from the event in order to track it (this is the main thing I learned from this, thank you
; however, in order to deal with the occasion of the newly created window layer suddenly appearing under the mouse (causing the window layer to flash incessantly instead of staying open), there still needs to be something else added, and the method I used in my previous solution is the only thing I can think of.
My only concern there would be that, in my infinite ignorance, is that the right/best way to be doing that?
Discussion follows, and then below that is my reworked solution using an augmentation of your code.
=========================================================
Discussion: testing...
In my previous solution, [summarizing]
I created a t.onmouseover function inside the init function in dhtmlwindow.js to be able to detect a mouseover event for any newly appearing layer. I do not know of another way to do this, or if this is the only way(?), but this detection appears to be necessary for handling a layer appearing under the mouse during document.mouseover events.
Then I create a function for setting a variable value, 'isclicked', for the document.onclick event, which I can then manipulate from the t.onmouseover function. This allows using 'isclicked' in other functions, like for controlling (killing or allowing) a document.onmouseout event in progress ;^).
So taken together the logic goes: "IF the link was clicked (document.click == true) AND IF the Layer appears under the mouse (window.layer.mouseover == true) THEN Kill the mouseout in progress (that automatically occurs if a layer appears inbetween the document and the mouse ;^)
In the case of this/your alternate code, as far as my limited understanding can deduce, since the init or open functions in dhtmlwindow.js cannot access the ajaxwin object/variable [can it?] it is unusable there. And since the "t" (object)variable cannot be accessed directly outside those functions, and it seems to be the only way to access the window.layer.mouseover event [is this correct?], then it would appear that there still needs to be added a t.onmouseover event function variable for detecting this, and then using that in the event handling functions (instead of ajaxwin.clickbool).
???
===========================
So, for instance, this method will work (but is it kosher or best? I do not know):
- Set variable isclicked for the document.onclick event
- Use init funct line: t.onmouseover=function() {isclicked = 1} //to detect mouseover popup layer event
- Then document mouseout event can be cancelled using that variable value
-----------------------
However, this method will not work...
t.onmouseover=function() {ajaxwin.clickbool = 1} //because it would seem that the object.variable is not accessible to the init function, and you cannot set it there,...
============================
=========================================================
So I was able to work out a solution utilizing your method by adjusting the code as follows below...
(Note: I go over these things as well as possible so it can be critiqued by the experts, since I am not the expert and something disasterous could be lurking in the code- unbeknownst to me!! I don't wish to be responsible for unwittingly teaching poor coding methods or logic to anyone ;^)
1) continue to use "t.onmouseover=function() {isclicked = 1}" I made in the init function
2) edit the/your 'boolean' function as follows...
Code:
function openmypage(clickbool){ //click (1) event 'handler' only (removed for mouseover)
// ajaxwin.clickbool=clickbool //remove this since it is not used anyway
isclicked = clickbool //i.e. we have to use this instead
ajaxwin.onclose=function(){
this.clickbool=0
isclicked=0
return true;
}
}
function hidemypage(){ //mouseout event 'handler'
if (isclicked == 0){
ajaxwin.hide(); return true
}
isclicked = 0
}
Note that openmypage() is used only for onclick, not for onmouseover, and that ajaxwin.clickbool is not used at all, but instead I am using isclicked.
3) I setup the document linking like this...
Code:
<a href="http://www.MYSITE.org/Test1.htm" title="Test1"
onMouseover="ajaxwin=dhtmlwindow.open('test1box', 'ajax', 'test1.htm', 'Open Window Test', 'width=300px,height=300px,left=60px,top=60px,resize=0,scrolling=1');"
onMouseout="hidemypage()"
onClick="ajaxwin=dhtmlwindow.open('test1box', 'ajax', 'test1.htm', 'Open Window Test', 'width=300px,height=300px,left=60px,top=60px,resize=0,scrolling=1'); openmypage(1); return false"><span style="color:yellow;">Create/ Open Window 3</span></a>
NOTE THAT:
1) openmypage(0) previously located in onmouseover is not needed, and its removal allows window.layer.mouseover detection to function correctly.
2) For those following, be sure to check out my second posting in this thread for setting a timeout delay (not shown here) for controlling document responses to the mouseover event (which can otherwise be annoying in certain applications)
3) href and title are used for compatability when the user has javascript turned off in their browser
=======================================
Well that's what I got so far. Is my logic sound? Is the code good?
Thank you very much for the 'setting a variable from the link event' lesson.
I look forward to any further comments. suggestion, corrections, etc ;^)
Cheers,
TwoHawks
Bookmarks