Web Analytics Made Easy -
StatCounter Esc sequences in java string - CodingForum

Announcement

Collapse
No announcement yet.

Esc sequences in java string

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Esc sequences in java string

    I would do this with DOM, but I'm almost at the end of task and wouldnt like to do it al again.

    Code:
    var myArray = new Array("a","b","c");
    
    // next line works
    s = s + "<img onClick = \"someFunc(new Array('a','b','c'));\"/>";
    
    // how to modify next line to work ?
    s = s + "<img onClick = \"someFunc(new Array(" + myArray.toString() + "));\"/>";
    
    someObj.innerHtml = s;
    thanks.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    I use single quotes in javascript
    Code:
    s = s + '<img onclick = "someFunc(new Array(\'' + myArray.toString() + '\'));" />';
    Please note javascript is NOT java. They are two totally different languages.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

    Comment


    • #3
      Pulling this on top, coz I'm stuck again:
      basicaly I need to transfer some HTML via AJAX to client, the problem that appears is like:

      Code:
      onclick= 'document.getElementById('foo').innerHTML = '<DIV style = 'overflow: hidden;'> ....</DIV>.....'
      --> a bunch of ' characters inside source string, how to esceape this ?

      Solved: vorks like this:
      Code:
        onclick= "document.getElementById('foo').innerHTML = '<DIV style = \'overflow: hidden;\'></DIV>'"
      Last edited by BubikolRamios; Dec 25, 2007, 03:25 PM.
      Found a flower or bug and don't know what it is ?
      agrozoo.net galery
      if you don't spot search button at once, there is search form:
      agrozoo.net galery search

      Comment

      Working...
      X