\startJSpreamble {Notes} used now

  var lastNote = "" ;

  function Show_Note ( Name )
    { if (Name != lastNote)
        { Hide_Note () ;
          var v = this.getField(Name) ; if (v)
            { console.println("Show Note: " + Name) ;
              v.display = display.visible ;
              v.readonly = false ;
              this.dirty = false ;
              lastNote = Name } } }

  function Hide_Note ( )
    { if (lastNote != "")
        { var v = this.getField(lastNote) ; if (v)
            { console.println("Hide Note: " + lastNote) ;
              v.display = display.hidden ;
              v.readonly = true ;
              this.dirty = false } }
          lastNote = "" }

\stopJSpreamble

\newcounter\AnotherNote

\def\SomeNote#1#2%
  {\hbox
     {\doglobal\increment\AnotherNote
      \definesymbol[note:\AnotherNote:on][\WhatANote{#2}]%
      \setupfield[notes][offset=overlay,frame=off,option={readonly,hidden}]
    % this confuses acrobat, probably some interference bug, I spent too much time on that
    % \setupfield[notes][offset=overlay,frame=off,option={readonly,hidden},clickin=JS(Hide_Note)]
      \definefield[note:\AnotherNote][check][notes][note:\AnotherNote:on][note:\AnotherNote:on]%
      \doifreferencefoundelse{note:\AnotherNote}
        {\setlayer[notes][page=\currentrealreference]{\fitfield[note:\AnotherNote]}}
        {\setlayer[notes]{\fitfield[note:\AnotherNote]}}%
      \pagereference[note:\AnotherNote]\goto{#1}[JS(Show_Note{note:\AnotherNote})]}}

\setupinteraction
  [state=start,
   openpageaction=JS(Hide_Note),
   closepageaction=JS(Hide_Note)]

\setupinteractionscreen
   [option=max]
   
\definereference[CloseNote][JS(Hide_Note)]

\setupfootertexts[{\goto{Fermer la note}[CloseNote]}][]
\setupcolors
  [state=start]

\definecolor
  [notebackgroundcolor]
  [s=.85]

\defineframedtext
  [WhatANote]
  [background=color,
   backgroundcolor=notebackgroundcolor,
   width=.45\textwidth,
   height=fit,
   align=normal,
   style=\ss,
   bodyfont=8pt]

\definelayer
  [notes]
  [width=\paperwidth,
   height=\paperheight,
   preset=rightbottom,
   offset=1cm]

\setupbackgrounds
  [page]
  [background=notes]


\defineXMLenvironment[note]
	{}
	{\SomeNote{(\XMLop{id})}{\getbuffer[\XMLop{id}]}}



\starttext
\startbuffer[3]
My note
\stopbuffer
\startXMLdata
Try <note id='3' />
\stopXMLdata
\stoptext 