pasteHTML

S

Simon Wigzell

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.pasteHTML(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.virtualcottageindustries.com/webpageRecordEditor.asp#Bottom
">Bottom</A>

Where http://www.virtualcottageindustries.com/webpageRecordEditor.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?
 
M

Michael Winter

[snip]
sRange.pasteHTML(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.virtualcottageindustries.com/webpageRecordEditor.asp#Bottom
">Bottom</A>

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.
 
W

William Morris

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!
 
S

Simon Wigzell

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top