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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 4th, 2003, 06:33 AM
c0redump c0redump is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 3 c0redump User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
createlink problem

Hi,

In my WYSIWYG editor i'm trying to upload a file and get the url on the page. I'm using the next (php)script to upload the file to my server:

if ($file) {
$destination = $file_name;
$destination = STR_REPLACE(" ","",$destination);
$dest = "data/".$destination;

if (move_uploaded_file($file, $dest)) {
echo "$destination saved";
echo("
<script language=javascript>\n
if(window.opener) window.opener.doUpload2('$destination');\n
setTimeout('self.close()',500);\n
</script>\n
");
} else {
echo "Error saving file";
}
}


The upload part works fine, but, to get the url to the file on my page i use the next javascript:


function doUpload2(fileName) {
url = "<? echo SITE_URL ?>/data/"+fileName ;
iView.document.execCommand("CreateLink",false,url);
}


Nothing happens. No url(not even the wrong) is shown in the editor.

I'm probally using the CreateLink command wrong, so my question is, How am I supposed to use this??

Reply With Quote
  #2  
Old February 11th, 2003, 04:23 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
try removing everything after the first parameter ("createlink") - it should pop up a window asking you for the URL.

Reply With Quote
  #3  
Old February 11th, 2003, 04:31 AM
c0redump c0redump is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 3 c0redump User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sure, but ofcourse that is not what I want... I want the name of the file to appear in my textarea and let it link to the url...
Can that be done??..

Reply With Quote
  #4  
Old February 11th, 2003, 04:58 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
I don't think you can format a textarea box. If you want to do stuff like that (bold, hyperlinking, etc) use an iFrame. Check out the "building a WYSIWYG" article on this site.

Reply With Quote
  #5  
Old February 11th, 2003, 05:02 AM
c0redump c0redump is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 3 c0redump User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
That's what I've got...but what i want is, just like the insertimage function, to create a link to the file I've just uploaded...

Now, I upload a file, copy its url, then in the wysiwyg editor I create a link and paste the url...This is not a very clean way...

Reply With Quote
  #6  
Old February 11th, 2003, 05:20 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
You may just have to insert the code directly into the editor, rather than using the createlink exec function.

This can be done using the pasteHTML() function.

Click here to see how to use it.

Reply With Quote
  #7  
Old March 11th, 2004, 02:11 PM
doubloon doubloon is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 2 doubloon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
createlink specifying target

function createLink() {
var reIMG = /(.*<[Ii][Mm][Gg].*)/ ;
if (!validateMode()) return;

var isA = getEl("A",Composition.document.selection.createRange().pare ntElement());
var str=prompt("Enter link location (e.g. http://www.sbpa.com):", isA ? isA.href : "http:\/\/");

if ((str!=null) && (str!="http://")) {
if (Composition.document.selection.type=="None") {
var sel=Composition.document.selection.createRange();
sel.pasteHTML("<A HREF=\""+str+"\" target=nw>"+str+"</A> ");
sel.select();
} else if (Composition.document.selection.type=="Text") {
var sel=Composition.document.selection.createRange();
if (sel.text.length > 0) {
sel.pasteHTML("<A HREF=\""+str+"\" target=nw>"+sel.text+"</A> ");
} else {
if (reIMG.test(sel.htmlText)) {
sel.pasteHTML("<A HREF=\""+str+"\" target=nw>"+sel.htmlText.replace(/(.*<A[^<]*)(<IMG[^<]*).*$/,'$2')+"</A> ");
} else {
format("CreateLink",str);
}
}
sel.select();
} else {
format("CreateLink",str);
}
}
else Composition.focus();
}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > createlink problem


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 2 hosted by Hostway