SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    pasteHTML problem

    I have an interesting situation where I need to pasteHTML "<script src=whatever.js></script>" using javascript. However, the "</script>" is being interpreted by the browser as ending the javascript before finsihing the job of pasting the HTML....

    <SCRIPT language="JavaScript">
    // Get a text range for the selection
    var tr = parent.page.document.selection.createRange()
    tr.pasteHTML("<script src=whatever.js></script>");
    </script>

    thanks,
    Dave

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2002
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script language="JavaScript">
    // Get a text range for the selection
    var tr = parent.page.document.selection.createRange()
    tr.pasteHTML("<script src=whatever.js><\/script>");
    </script>
    Try the above. ( See the closing script tag? ) You always want to escape closing tags to make sure this doesn't happen.


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
  •