[Javascript] parse question
Scott Reynen
scott at randomchaos.com
Mon Feb 26 13:43:48 CST 2007
On Feb 26, 2007, at 10:36 AM, tedd wrote:
> The following is the function that's giving me problems.
>
> HsExpander.prototype.writeCredits = function ()
> {
> var credits = hs.createElement
> ('a',
> {
> href: this.a,
> className: 'highslide-credits',
> innerHTML: hs.creditsText,
> title: hs.creditsTitle
> }
> );
> this.createOverlay(credits, 'top left');
> };
>
> When the "credits" are shown "this.a" will produce:
>
> http://www.mydomain.com/firstdir/secondir/myfile.txt
>
> However, no matter what I've tried, including all your suggestions
> and more, I can't reduce this to "myfile.txt".
>
> There's something different going on here that I don't understand
> -- any explanation or solution?
I'm not entirely clear on what you're doing here, but it looks like
you're setting the href attribute of an <a> node to a relative
"myfile.txt" and then when you go to get that value, it's been
changed to the full path of "http://www.mydomain.com/firstdir/
secondir/myfile.txt". I think it's standard for browsers to
dereference relative paths as they're set in the DOM, so the full
path can be immediately available (e.g. as a status message on
mouseover). I suspect you'll need to pull out the last path fragment
in the createOverlay function rather than setting it in the
writeCredits function if you want it to persist.
Peace,
Scott
More information about the Javascript
mailing list