problem to insert script

Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.

  1. #1

    Default problem to insert script

    Hi outthere, I made an extension which inserts a piece of javascript into the
    source, including: <script>...</script> and <noscript>...</noscript>. By using
    this extension in codeview everything works fine. Here comes the problem: In
    the designview the script maybe is inserted between an open <p> tag. If now the
    user is writing something, he'll writes it into the <noscript></noscript> area
    and not after the hole piece of JS which has been pasted into the code. How
    can I avoid this? Hope you know what I mean... CU, drerolf

    drerolf Guest

  2. Similar Questions and Discussions

    1. Insert NULL not Blank into MySQL with PHP Script
      Hi, Here's my question: How do I pass a NULL value in a variable to a MySQL DB? Here's an overview of my problem: I have a PHP page that...
    2. Insert data in DB by using the script
      Hi, I have an sql script (generated by php) which contains only INSERT commands. The sql script should be launched everyday in order to insert...
    3. ' & insert problem
      Hi, Whats the best way to handle clients submitting ' in form fields i.e. richard's would throw an error when using sql to insert into the...
    4. Problem with insert
      I have the following code in an ASP page that is processing a form to create a new user. I keep getting the following error Microsoft JET...
    5. multiple insert problem !
      hi ! had to come right back... this time i'm trying to do a multiple insert. in my admin website i want to add users to a specific project. i...
  3. #2

    Default Re: problem to insert script

    drerolf wrote:
    > Hi outthere, I made an extension which inserts a piece of javascript into the
    > source, including: <script>...</script> and <noscript>...</noscript>. By using
    > this extension in codeview everything works fine. Here comes the problem: In
    > the designview the script maybe is inserted between an open <p> tag. If now the
    > user is writing something, he'll writes it into the <noscript></noscript> area
    > and not after the hole piece of JS which has been pasted into the code. How
    > can I avoid this? Hope you know what I mean... CU, drerolf
    How are you diong the insert?

    It may be possible to insert your code, and place the insertion point after the noscript block. However, I don't think you will be able to prevent folks from being able to type in that location later.

    --
    Danilo Celic
    | Extending Knowledge Daily : [url]http://CommunityMX.com/[/url]
    | Team Macromedia for Dreamweaver : [url]http://macromedia.com/go/team/[/url]
    danilocelic *TMM* Guest

  4. #3

    Default Re: problem to insert script

    Thanks for your reply, The script is inserted in place (cursor position) via
    the objectTag(). The cursor should stay after: <script>...</script> and
    <noscript>...</noscript> HERE. Design-view can't show javascript, so it shows
    the text between the noscript e.g.: 'JS is disabled'. Cursor stands after
    'disabled'. Changing to codeview shows the same result - cursor stands after
    'disabled' and not after the </noscript> tag. If now the user inserts some
    text, he writes it between the <noscript>...</noscript> You wrote: >However, I
    don't think you will be able to prevent folks from being able to type in that
    location later. They could do what they want, but those who hasn't much
    experience are writing between <noscript>...</noscript>... , but I mentioned
    that already. ;-) Any ideas? Thanks a lot. drerolf

    drerolf Guest

  5. #4

    Default Re: problem to insert script

    drerolf wrote:
    > Thanks for your reply, The script is inserted in place (cursor position) via
    > the objectTag(). The cursor should stay after: <script>...</script> and
    > <noscript>...</noscript> HERE. Design-view can't show javascript, so it shows
    > the text between the noscript e.g.: 'JS is disabled'. Cursor stands after
    > 'disabled'. Changing to codeview shows the same result - cursor stands after
    > 'disabled' and not after the </noscript> tag.
    Try using insertObject(), rather than objectTag(), with code similar to the following:

    function insertObject(){
    var objectCode = '<script>...</s' + 'cript><noscript>...</nos' + 'cript>';
    var dom = dw.getDocumentDOM();
    dom.insertHTML(objectCode);
    return '';
    }

    When that is run, it inserts the block of code and it is hightlighted. If they immediately type it will wipe out the addition, as is true of any selection. If they arrow off the selection to the left, they will be placed before the opeing of the <script> tag, and it they arrow off to the right, they will be after the closing </noscript> tag.


    Note: I'm breaking up the closing tags becuase 1) you have to for the closing script tag as DW will think its the close of the containg script block, and 2) thought it would be safe to do the same with te noscript, but maybe not required.


    --
    Danilo Celic
    | Extending Knowledge, Daily [url]http://CommunityMX.com/[/url]
    danilocelic *TMM* Guest

  6. #5

    Default Re: problem to insert script

    Hi danilocelic, Thanks a lot for your help. I nearly stopped working on this
    extension. But now: It works perfectly! I'm not sure if changing objectTag()
    or insertObject() was the point. What I've been ignored was breaking up the
    closing tags. (foolish mistake) Maybe that was the point. Your help is very
    much appreciated. Well, have a beer from me (someday, if we meet ;-) ! CU,
    drerolf

    drerolf Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139