|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
My script below works fine in WebPublisher to create multiple links based on two fields - the Video link field (linkv) and the Title of the video (titlev). However it does not always work when I concatenate the fields to create a clickable link. If have urls have spaces (like in the array example below) the hyperlink stops at the space even though I can get script to successfully write the full video link outside of a concatenated html string for a hyperlink. Any thoughts?
<SCRIPT language="JavaScript"><!-- var linkv = new Array ("http://intranet/program 1.htm","http://intranet/program 2.htm","http://intranet/program 3.htm","http://intranet/program 4.htm","http://intranet/program 5.htm","http://intranet/program 6.htm"); var titlev= new Array ("Program 1","Program 2","Program 3","Program 4","Program 5","Program 6"); nentry = linkv.length; nentry1 = titlev.length; for (i = 0; i < nentry; i++) { f1 = linkv[i].toString(); // Convert entry to string f2 = titlev[i].toString(); // Convert entry to string str = "<a href=" + f1 + ">" + f2 + "</a><br>"; // Concatenate document.write(str); } //--></SCRIPT> This message has been edited. Last edited by: JennM, |
|||
|
Okay figured it out... and have replaced spaces with %20
for (i = 0; i < nentry; i++) { f1 = linkv[i].toString(); // Convert entry to string f1 = f1.replace(/\s/g,"%20") f2 = titlev[i].toString(); // Convert entry to string str = "<a href=" +f1 + ">" + f2 + "</a><br>"; // Concatenate document.write(str); |
||||
|
JennM ---
You're probably best off url-encoding the URL strings in your array right off the bat, rather than selectively replacing spaces with %20. Thus you will ensure that *all* characters are URL safe, not just spaces. E.g.
var linkv = [encodeURI("your link string"), encodeURI("another link string"), etc.];
js encode method comparisons Peter Tyrrell, MLIS Senior Consultant Andornot Consulting Inc. http://www.andornot.com/about/developerblog |
||||
|
Thanks Peter. I will try that.
|
||||
|
| Previous Topic | Next Topic | powered by eve community |
| Please Wait. Your request is being processed... |
|

