SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Autoquote hack for forum

    I added a quick reply hack to an EZBoard forum I help admin. I want to add an auto quote feature where when a use highlights any text, it opens a popup where they have the option to insert into the quick reply form with the ezcodes quote tags added. They also have the option to copy to clipboard and can paste with the quote tags again added w/o having to use the quote button. It works fina locally, but on a server, and especially when the js file is included remotely from the forum I get JS errors. Below is a link to a test file and it works except for the clipboard function in Firefox and I get a UniversalXPConnect privilages error.

    Test Form

    The scripts:

    http://trilogyaudiometrics.com/dev/test_form.phps
    http://trilogyaudiometrics.com/dev/auto_quote.phps

    Any insight on this would be much appreciated.

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Great feature.

    I think the error has to do with js security--I don't think I would want a script to have access to my clipboard and possibly steal my credit card number or some passwords I cut and pasted into Paypal--or is the script creating its own clipboard?

  3. #3
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have to sign your script in order to obtain UniversalXPConnect.

    See http://docs.mandragor.org/files/Misc...12-sect-6.html

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Another auto version

    Well, it looks like the security issues will nix the previous quote code. This is a simpler version using a JS prompt. It works fine in Firefox, but I get a JS error in IE at the "document.forms['PostMessage'].body.value += selection;" line. The error is "document.forms.PostMessage.body is null or not an object". Below is the new code:


    Source file:
    Autoquote using prompt

    Example:
    Autoquote using prompt

  5. #5
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you actually name an element of your form 'body'? document.body is a reference to the <body> tag, and forms don't have a <body> tag.

  6. #6
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It was some genius that wrote the EZBoard code who named the reply textarea "body". Nothing I can do about that. I may try having it detect IE and dump it to a hidden input, then have the quick reply form check for a value in the input.

  7. #7
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could change the reference by getting a collection of the <textarea>'s using document.getElementsByTagName, and refer to it by it's position in the array.

  8. #8
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should probably try this first:

    document.forms['PostMessage'].elements['body'].value +=


Bookmarks

Posting Permissions

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