www.webdeveloper.com
Results 1 to 2 of 2

Thread: What is in this function call?

  1. #1
    Join Date
    Sep 2008
    Posts
    12

    Exclamation What is in this function call?

    I have a function called InsertSmiley. It inserts an image into a text editor. I got all the source code for this from FCKeditor. I am going to be playing around a little with the call of this function and just want to understand the syntax here.

    Could someone explain to me what this call is doing? Particularly after the pUrl.replace.

    Code:
    onclick="InsertSmiley(\'' + pUrl.replace(/'/g, "\\'" ) + '\')"
    Thanks!

  2. #2
    Join Date
    Sep 2008
    Posts
    408
    It is replacing a ' with \' globally. (g = globally)

    That is usually done when a page is going to be stored into a database so it doesn't break the code.

    So:

    Code:
    var str = "This is a 'test' string";
    str.replace(/'/g, "\\'");
    
    window.alert(str) // alerts: This is a \'test\' string
    Mullanaphy!
    http://www.mullanaphy.com/

    Unless code is provided or an exact example is requested I think I'm going to start using psuedo code from now on...

    Also, I freelance as well. Inquire within!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles