Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

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:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old December 22nd, 2002, 06:39 AM
theghostofbob theghostofbob is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Auckland, New Zealand
Posts: 3 theghostofbob User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry [javascript] pasteHTML changing text

Hi All,
I am having trouble using the pasteHTML function in javascript for my online WYSIWYG editor.

Here is the javascript code (loc is the location of the link):
PHP Code:
function sendLink(loc) {
    var 
win1 "";
    if(
document.linkForm.window.value == "new") {
        
win1 "target=\"_new\"";
        
//window.alert(win1);
    
}
    var 
selectedText window.opener.editFrame.document.selection.createR  ange();
    var 
text selectedText.htmlText;
    var 
link "<A HREF=\""+loc+"\" "+win1+">"+text+"</A>";
    
window.alert(link);
    
selectedText.pasteHTML(link);
    
window.close();



The code is in a popup window and inserts a link in the editFrame of the parent window.
The alert box might say the following:
<A HREF="airport.htm" target="_new">Airport Link</A>
but it inserts the following
<A target=_new HREF="airport.htm">Airport Link</A>
which wont open in a new window.

Unfortunately I dont think I can use execCommand for this.

Thanks in advance for any help and Seasons Greetings to you all

theghostofbob

Reply With Quote
  #2  
Old December 22nd, 2002, 02:58 PM
dgibson dgibson is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Urbana, MD, USA
Posts: 66 dgibson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
I was under the impression that pasteHTML was only invoked by execommand(), but I have not used it enough to recall.

Also, be careful when you use alerts for dubugging like this. I have seen people do this (and fall prey to it myself on occasion) and not realize that the alert is changing the focus on the page and can therefore create unwanted effects while testing. Is your selection still active that you are trying to replace when focus is returned form teh alert? Try commenting it out and try again if you haven't.

Reply With Quote
  #3  
Old December 22nd, 2002, 10:12 PM
theghostofbob theghostofbob is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Auckland, New Zealand
Posts: 3 theghostofbob User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks for the reply

turns out that the change doesnt matter, the link still works. I needed to be using target="_blank" not target="_new"

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > [javascript] 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 | 
  
 

Iron Speed




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