Well that would depend on whether the original document.location.href
returned a absolute or relative url wouldn't it?
You should make sure that the url is either absolute or relative,
depending on how you have your links defined.
something like url.replace("http://www.yourdomain.com/", "") should do
the trick if you have relative paths in your links.
On 1/27/07, Rose, Ryan <[EMAIL PROTECTED]> wrote:
> Try matching the url with this: $("[EMAIL PROTECTED]'"+url+"']").each(....
>
> It should find a match whether the url is absolute or relative.
>
> Ryan Rose
> http://www.digiwize.com
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of George Adamson
> Sent: Saturday, January 27, 2007 9:15 AM
> To: [email protected]
> Subject: Re: [jQuery] remove in-page links with plain text
>
>
> Removing self-links from a page is good plan though it will only work
> for
> js-enabled users. Standard readers will still see the full links so this
> is
> not a very accessible solution. Best to do it server-side if possible.
>
> Anyway, regarding your specific questions:
> > 1) "I need a way to not to add the span tag for any links under who's
> > parent node is a H1."
> Not sure what you mean about the span tag, sorry. Can you use .filter()
> or
> .not() to do this?
>
> > 2) "in need of tiding up..."
> Here's some code to simplify things a bit:
>
> var url = document.location.href;
>
> $("[EMAIL PROTECTED]'" + url + "']").each(function(){
>
> var $this = $(this);
> var txtEl = document.createTextNode( $this.text() );
> $this.parent()[0].replaceChild(txtEl, this);
>
> })
>
> A word of caution: When reading A.href from code code you may find it
> varies
> depending on the browser. It may or may not include the full url path.
> This
> will cause it not match the document.location.href. Perhaps you could
> experiment with "$=" instead of "=" in the selector syntax (see jquery
> selector docs)
>
> George
>
>
> ProDevStudio wrote:
> >
> > Hello everyone,
> >
> > Just started using jquery. I have a situation where I have solution
> but
> > need your help in making it do what I want.
> >
> > I have a page which has many links and I want to remove the links to
> > current page (i.e links to the page itself).
> >
> > This is what I am after:
> >
> ------------------------------------------------------------------------
> -----------------------
> > before:
> > ..<h1>...< a href="page.html">thispage ...</h1>...
> > ...<li>< a href="page.html">thispage </li>...
> >
> > after:
> > ..<h1>...thispage...</h1>...
> > ...<li>thispage</li>...
> >
> ------------------------------------------------------------------------
> -----------------------
> >
> > This is what I have so far:
> >
> > $(document).ready(function(){
> > // if the location is same as href then remove it
> > ($('[EMAIL PROTECTED]' + window.location.href + ']').size()>1)?($('[EMAIL
> > PROTECTED]' +
> > window.location.href + ']').not($('[EMAIL PROTECTED]' +
> > window.location.href +
> > ']')[0]).after(''+$('[EMAIL PROTECTED]' + window.location.href +
> > ']').text()+'').remove()):($('[EMAIL PROTECTED]' + window.location.href +
> > ']').after(''+$('[EMAIL PROTECTED]' + window.location.href +
> > ']').text()+'').remove());
> > });
> >
> > It works excepts 2 things:
> >
> > 1) I need a way to not to add the span tag for any links under who's
> > parent node is a H1. I can avoid this if I can filter all the links to
> > ul>li>a items.
> >
> > 2) the above code itself is looks very ugly and in need of tiding up.
> (I
> > can tidy this easily only If I know how I can load the object into a
> > variable in jquery way and use that in places instead of repeating the
> > same same code over and over)
> >
> > Any help is welcomed.
> >
> > Thanks in advanced.
> >
> > ProDevStudio
> >
>
> --
> View this message in context:
> http://www.nabble.com/remove-in-page-links-with-plain-text-tf3123240.htm
> l#a8666262
> Sent from the JQuery mailing list archive at Nabble.com.
>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
--
——————————————
Med Vänliga Hälsningar
Kristinn "Kiddi" Sigmundsson
0707-971938
——————————————
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/