|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
I am trying to use the pasteHTML to create a link in my WYSIWYG HTML editor, so that i can a link with target and name.
Here is my test code: var strValue = '<a href="#Help">Click here for help</a>'; var curRange = oEditor.document.selection.createRange(); curRange.pasteHTML(strValue); Somehow my output become <a href="http://localhost/editor/editor.cfm#Help">Click here for help</a> anyone know how to solve this problem, i using DIV to create my WYSIWYG HTML editor. |
|
#2
|
||||
|
||||
|
The pasteHTML function automatically prepends the current URL if you don't provide one, I believe. Try passing a full URL to your anchor tag and see if that works.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
|||
|
|||
|
But I can't pre-defined the full URL, because the user may change the filename or location of the file after using the WYSIWYG HTML Editor.
|
|
#4
|
||||
|
||||
|
Then you'll have to do a regex server side to strip out any info you don't want in there.
|
|
#5
|
|||
|
|||
|
There is a solution to the problem -
just before the "pasteHTML" function, do a "cutHTML" not sure why this works, but hey, it does the trick. var strValue = '<a href="#Help">Click here for help</a>'; var curRange = oEditor.document.selection.createRange(); curRange.cutHTML; curRange.pasteHTML(strValue); |
|
#6
|
|||
|
|||
|
please tell me what's cutHTML, I cannot find ti in msdn. and it cannot do anything! thank you
|
|
#7
|
|||
|
|||
|
anybody help me!
I have the same question.
and the cutHTML can't work. |
|
#8
|
|||
|
|||
|
You can do it in a more simpla way using execCommand:
function gce_createlink() { document.getElementById('myEditor').contentWindow. focus(); if (!document.all) { var szURL = prompt(msg_code[1], "http://"); document.getElementById('myEditor').contentWindow. document.execCommand('createlink', false, szURL); } else { document.getElementById('myEditor').contentWindow. document.execCommand('createlink', true, null); } } enjoy it |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > WYSIWYG pasteHTML changing text |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|