JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old March 10th, 2004, 03:26 PM
jtan jtan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 2 jtan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy WYSIWYG pasteHTML changing text

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.

Reply With Quote
  #2  
Old March 11th, 2004, 11:20 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
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.

Reply With Quote
  #3  
Old March 14th, 2004, 03:37 PM
jtan jtan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 2 jtan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old March 15th, 2004, 07:03 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Then you'll have to do a regex server side to strip out any info you don't want in there.

Reply With Quote
  #5  
Old March 26th, 2004, 06:30 AM
pelfed pelfed is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Wiltshire- UK
Posts: 15 pelfed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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);

Reply With Quote
  #6  
Old July 21st, 2004, 02:07 AM
lionzhf lionzhf is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 lionzhf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
please tell me what's cutHTML, I cannot find ti in msdn. and it cannot do anything! thank you

Reply With Quote
  #7  
Old February 17th, 2006, 12:49 AM
flyingknife flyingknife is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 1 flyingknife User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 39 sec
Reputation Power: 0
anybody help me!

I have the same question.

and the cutHTML can't work.

Reply With Quote
  #8  
Old February 18th, 2006, 04:08 AM
goldrake73 goldrake73 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 7 goldrake73 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 30 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > WYSIWYG pasteHTML changing text


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway