Associate onclick to wz_jsgraphics objects.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • guciccon
    New Member
    • Sep 2007
    • 5

    Associate onclick to wz_jsgraphics objects.

    I'll try to use wz_jsgraphics.j s library. Is it possible to associate the instruction "onclick" in the tag div generates to construct the design ? I have tried, works on FireFox but not on IE.

    Thanks in advance.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Welcome to TSDN!

    Are you using setAttribute? That won't work in IE. Use the old syntax:
    [CODE=javascript]element.onclick =doSomething;[/CODE]

    Comment

    • guciccon
      New Member
      • Sep 2007
      • 5

      #3
      Originally posted by acoder
      Welcome to TSDN!

      Are you using setAttribute? That won't work in IE. Use the old syntax:
      [CODE=javascript]element.onclick =doSomething;[/CODE]
      This is the function:
      [CODE=javascript]
      function mkDiv(x, y, w, h)
      {
      this.htm += '<div style="position :absolute;'+
      'left:' + x + 'px;'+
      'top:' + y + 'px;'+
      'width:' + w + 'px;'+
      'height:' + h + 'px;'+
      'clip:rect(0,'+ w+'px,'+h+'px,0 );'+
      'background-color:' + this.color +
      (!jg_moz? ';overflow:hidd en' : '')+
      '; onclick="alert( "test")"><\/div>';
      }[/CODE]

      In this case, I think is not possible to apply you have suggested (I'm not expert, perhaps I'm wrong)
      Last edited by acoder; Sep 21 '07, 04:31 PM. Reason: Added code tags

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Please use code tags when posting code.

        You need to escape the double quotes within double quotes, e.g.
        Code:
        onclick="alert(\"test\")"

        Comment

        • guciccon
          New Member
          • Sep 2007
          • 5

          #5
          Originally posted by acoder
          Please use code tags when posting code.

          You need to escape the double quotes within double quotes, e.g.
          Code:
          onclick="alert(\"test\")"
          I'm sorry, but it doesn't work on IE.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by guciccon
            I'm sorry, but it doesn't work on IE.
            You've not closed the style declaration:
            [CODE=javascript](!jg_moz? ';overflow:hidd en' : '')+
            ';" onclick=...[/CODE]Notice the double quote before onclick.

            Comment

            • guciccon
              New Member
              • Sep 2007
              • 5

              #7
              Originally posted by acoder
              You've not closed the style declaration:
              [CODE=javascript](!jg_moz? ';overflow:hidd en' : '')+
              ';" onclick=...[/CODE]Notice the double quote before onclick.
              This is the code:

              [CODE=javascript](!jg_moz? ';overflow:hidd en' : '')+
              ';" onclick="alert( \"test\")">< \/div>';[/CODE]

              but it doesn't work. Thanks for your suggested.

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Originally posted by guciccon
                This is the code:

                [CODE=javascript](!jg_moz? ';overflow:hidd en' : '')+
                ';" onclick="alert( \"test\")">< \/div>';[/CODE]

                but it doesn't work. Thanks for your suggested.
                OK, try escaping single quotes instead:
                [CODE=javascript](!jg_moz? ';overflow:hidd en' : '')+
                ';" onclick="alert( \'test\')"><\/div>';[/CODE]

                Comment

                • guciccon
                  New Member
                  • Sep 2007
                  • 5

                  #9
                  Originally posted by acoder
                  OK, try escaping single quotes instead:
                  [CODE=javascript](!jg_moz? ';overflow:hidd en' : '')+
                  ';" onclick="alert( \'test\')"><\/div>';[/CODE]
                  It's work. Thank you.

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    Originally posted by guciccon
                    It's work. Thank you.
                    Glad to hear you got it working. Post again if you have any more questions.

                    Comment

                    Working...