View Full Version : 'A HREF' question
03-17-2004, 07:46 PM
i have the following line of code:
document.write("<BR><A HREF=" + aFile.Path + " TARGET=_blank>" + aFile.Path + "</A>")
the second aFile.Path lists the path of the file just fine.
03-17-2004, 07:52 PM
Try using location.host.
document.write("<BR><A HREF=" +location.host+ aFile.Path + " TARGET=_blank>" + aFile.Path + "</A>")
03-17-2004, 08:05 PM
Don't forget to escape().
document.write("<BR><A HREF=" + location.host + escape(aFile.Path) + " TARGET=_blank>" + aFile.Path + "</A>")
03-17-2004, 08:17 PM
thank you for the suggestions, but i'm not having success with either.
when i include location.host, the path of aFile doesn't print.
when i include the escape(), nothing prints.
03-17-2004, 08:54 PM
I wonder if instead of escape(), you were to use urlencode()...
Try that and let us know what happens,
03-17-2004, 09:09 PM
Encoding the url as Sadiq suggested is mandatory if the text comes from a user input and you want to avoid the possibility of cross site scripting but another basic problem is the fact that you left off the QUOTE marks that should surround ALL html properties. Yes, I realize the browsers will accept unquoted properties but I also know that any time there's an embedded space or other unusual character in that text this is the kind of problem that results.
03-17-2004, 09:22 PM
If this is not hosted but rather being used locally.
location.host will obviously not work.
example: folder called "Example Folder" only shows "...\Example",
03-18-2004, 02:25 AM
Roy's got it I think.
document.write("<BR><A HREF='" + aFile.Path + "' TARGET='_blank'>" + aFile.Path + "</A>")
03-18-2004, 04:05 AM
That's right. But double quotes is recommended to use in attribute values.
document.write('<br /><a href="' + aFile.Path + '" target="_blank">' + aFile.Path + '</a>')
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.