pasteHTML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Wigzell

    #1

    pasteHTML

    I'm using a 3rd party (htmlarea) WYSIWYG html editting tool. it works great
    most of the time. I have a problem where I've made my own function to create
    a bookmark type link. e.g. I want to turn the word "Bottom" into a link to
    the bottom of the page where resides a bookmark e.g. <a name="Bottom"></a>

    The 3rd party software in it's guts has this command:

    sRange.pasteHTM L(str1 +sHtml+ str2)

    Where str1 = <a href="#Bottom">
    sHtml = Bottom
    str2 = </a>

    sRange is the highltighted text that I want to make a link.

    So you would expect it to make a string like this:

    <a href="#Bottom"> Bottom</a>

    However, it makes a string like this :

    <A
    href="http://www.virtualcott ageindustries.c om/webpageRecordEd itor.asp#Bottom
    ">Bottom</A>

    Where http://www.virtualcottageindustries....cordEditor.asp is the
    page that contains the 3rd party WYSIWYG editor. The HTML text I'm creating
    here gets saved to a database and then used to generate a web page of a
    completely different name. All I want is this : <a href="#Bottom"> Bottom</a>

    Any ideas?


  • Michael Winter

    #2
    Re: pasteHTML

    On Mon, 19 Apr 2004 18:24:42 GMT, Simon Wigzell <simonwigzell@s haw.ca>
    wrote:

    [snip]
    [color=blue]
    > sRange.pasteHTM L(str1 +sHtml+ str2)
    >
    > Where str1 = <a href="#Bottom">
    > sHtml = Bottom
    > str2 = </a>
    >
    > sRange is the highltighted text that I want to make a link.
    >
    > So you would expect it to make a string like this:
    >
    > <a href="#Bottom"> Bottom</a>
    >
    > However, it makes a string like this :
    >
    > <A
    > href="http://www.virtualcott ageindustries.c om/webpageRecordEd itor.asp#Bottom
    > ">Bottom</A>[/color]

    Are you certain that this is generated by the script, or did you determine
    it some other way[1]? Don't forget that "#Bottom" is a relative URL that
    will use the current URL[2] to resolve the actual destination. If it does
    generate that URL, try including the filename for the page and if that
    fails, try an absolute URL.

    [snip]

    Mike


    [1] I don't mean to patronise. I'm just trying to be thorough.
    [2] Unless a base URL has been explicitly specified with the BASE element.

    --
    Michael Winter
    M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

    Comment

    • William Morris

      #3
      Re: pasteHTML

      I have used HTMLArea to good effect in my own applications. It's a helluva
      tool.

      According to MSDN re: the pasteHTML method:

      <quote>
      This method might alter the HTML text to make it fit the given text range.
      For example, pasting a table cell into a text range that does not contain a
      table might cause the method to insert a table element. For predictable
      results, paste only well-formed HTML text that fits within the given text
      range.
      </quote>

      Now, given Microsoft's well-meaning but pita propensity to "help" us by
      doing a lot of work for us, we might be able to assume from the paragraph
      above that when the browser detects a named link it automatically "helps" by
      putting the rest of the url in.

      So, question: what happens if you leave out the pound sign? Does it go in
      the way you want it to then?
      Second question: what happens if you break the string with the pound sign
      into more pieces, i.e.: str1 = "< href=""", str2="#", str3="Bottom""> ", and
      so on.
      Barring that, what happens if you put in the string thusly: str1 = "<a
      href=""" & chr(35) & "Bottom"">" ...


      --
      William Morris
      Semster, Seamlyne reProductions
      Visit our website, http://www.seamlyne.com, for the most comfortable
      historically inspired clothing you can buy!




      "Simon Wigzell" <simonwigzell@s haw.ca> wrote in message
      news:KPUgc.1803 34$Ig.17392@pd7 tw2no...[color=blue]
      > I'm using a 3rd party (htmlarea) WYSIWYG html editting tool. it works[/color]
      great[color=blue]
      > most of the time. I have a problem where I've made my own function to[/color]
      create[color=blue]
      > a bookmark type link. e.g. I want to turn the word "Bottom" into a link to
      > the bottom of the page where resides a bookmark e.g. <a name="Bottom"></a>
      >
      > The 3rd party software in it's guts has this command:
      >
      > sRange.pasteHTM L(str1 +sHtml+ str2)
      >
      > Where str1 = <a href="#Bottom">
      > sHtml = Bottom
      > str2 = </a>
      >
      > sRange is the highltighted text that I want to make a link.
      >
      > So you would expect it to make a string like this:
      >
      > <a href="#Bottom"> Bottom</a>
      >
      > However, it makes a string like this :
      >
      > <A
      >[/color]
      href="http://www.virtualcott ageindustries.c om/webpageRecordEd itor.asp#Bottom[color=blue]
      > ">Bottom</A>
      >
      > Where http://www.virtualcottageindustries....cordEditor.asp is[/color]
      the[color=blue]
      > page that contains the 3rd party WYSIWYG editor. The HTML text I'm[/color]
      creating[color=blue]
      > here gets saved to a database and then used to generate a web page of a
      > completely different name. All I want is this : <a[/color]
      href="#Bottom"> Bottom</a>[color=blue]
      >
      > Any ideas?
      >
      >[/color]


      Comment

      • Simon Wigzell

        #4
        Re: pasteHTML

        Thanks both, I've decided to fix it by using the asp replace function to
        remove the offending string.

        "Simon Wigzell" <simonwigzell@s haw.ca> wrote in message
        news:KPUgc.1803 34$Ig.17392@pd7 tw2no...[color=blue]
        > I'm using a 3rd party (htmlarea) WYSIWYG html editting tool. it works[/color]
        great[color=blue]
        > most of the time. I have a problem where I've made my own function to[/color]
        create[color=blue]
        > a bookmark type link. e.g. I want to turn the word "Bottom" into a link to
        > the bottom of the page where resides a bookmark e.g. <a name="Bottom"></a>
        >
        > The 3rd party software in it's guts has this command:
        >
        > sRange.pasteHTM L(str1 +sHtml+ str2)
        >
        > Where str1 = <a href="#Bottom">
        > sHtml = Bottom
        > str2 = </a>
        >
        > sRange is the highltighted text that I want to make a link.
        >
        > So you would expect it to make a string like this:
        >
        > <a href="#Bottom"> Bottom</a>
        >
        > However, it makes a string like this :
        >
        > <A
        >[/color]
        href="http://www.virtualcott ageindustries.c om/webpageRecordEd itor.asp#Bottom[color=blue]
        > ">Bottom</A>
        >
        > Where http://www.virtualcottageindustries....cordEditor.asp is[/color]
        the[color=blue]
        > page that contains the 3rd party WYSIWYG editor. The HTML text I'm[/color]
        creating[color=blue]
        > here gets saved to a database and then used to generate a web page of a
        > completely different name. All I want is this : <a[/color]
        href="#Bottom"> Bottom</a>[color=blue]
        >
        > Any ideas?
        >
        >[/color]


        Comment

        Working...