Results 1 to 9 of 9

Thread: Howto change <p></p> tags to <br> tags on pressing enter?

  1. #1
    Join Date
    Jun 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Howto change <p></p> tags to <br> tags on pressing enter?

    When pressing "enter" it closes </p> tag and opens new.
    Is it possible to change this feature to include <br> tag without <p>?

    Could not find this procedure in wysiwyg.js.

    Thanks in advance.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Please include a link to the DD script in question in your post. See this thread for the proper posting format when asking a question.


    I think you're referring to the openWYSIWYG editor?

    That code is pretty complex. I've changed a couple things, but it's hard to find stuff in it. I'll take a look.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jun 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Oops, sorry, of course it was about openWYSIWYG editor

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Meh. I dunno. That javascript is very complex.

    It uses a function to write more calls to other functions on the page, at which point I'm lost.

    Yeah, I'm looking through it and I can't find anything about converting to html. I don't think it's based on the event of the user hitting enter, but rather in some converting thing that the text is run though, where it converst a line break to <p>, but I still can't find it.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Jun 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Write one more function to convert <p></p> to <br> on the fly?

  6. #6
    Join Date
    Jun 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Cause I think that that tags are included by browser in DHTML...

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I could write a function in php to do that easily; just not sure how to do so in JS.

    PHP Code:
    <?php
    //assume $text is the final text:
    $text str_replace('<p>','<br>',$text);
    $text str_replace('</p>','',$text);
    //now $text has <br> instead of <p></p>
    ?>
    All you'd need is the function to do a string replace in javascript (surely there is one), and call it onSubmit in the form tag.



    Also, in dreamweaver, if you press shift+enter, it inserts a <br> instead of <p> tag. I was thinking this script worked in the same way, so I tried it out.
    But... whatever I did, I just got <br> tags... no <p> tags. I don't get it.
    Now... technically, since I'm on a mac, I'm pressing return, but I don't know if that is actually different in terms of javascript. It still enters a line break, so it would be seen in the same way by the JS.
    Anyway.... any ideas why we're getting different things?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Jun 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    In IE it works perfectly, on Shift+Enter it adds <BR> tag, on pure Enter it adds <P></P> tags.
    Is there any way to switch the behaviour? On pure Enter - <BR>, on Shift+Enter <P>...? Or just emulate the pressed shift button...

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Good question.

    The issue is finding the coding, not changing it. If you find where it controls that in the JS, should be VERY easy to switch. But I can't find it...
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •