|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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?? |
|
#2
|
||||
|
||||
|
try removing everything after the first parameter ("createlink") - it should pop up a window asking you for the URL.
|
|
#3
|
|||
|
|||
|
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??.. |
|
#4
|
||||
|
||||
|
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.
|
|
#5
|
|||
|
|||
|
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... |
|
#6
|
||||
|
||||
|
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. |
|
#7
|
|||
|
|||
|
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(); } |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > createlink problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|