Not sure about that, but one advantage of full URLs is that they work in all feed readers. I was using "root-relative" URLs on my blog until somebody complained that these links wouldn't work for him in his feed reader.

--Karl


On Dec 5, 2008, at 11:29 AM, Andy Matthews wrote:


As an FYI, while I personally prefer relative URLs for simplicity and
code reuse, full URLs in the HREF attribute provide slightly better
SEO due to the replication of the domain name.

On Dec 5, 10:23 am, Andy Matthews <[EMAIL PROTECTED]> wrote:
Here's a reference URL by the way:

http://www.hscripts.com/tutorials/javascript/document-object.php

On Dec 5, 10:21 am, "Andy Matthews" <[EMAIL PROTECTED]> wrote:

Matthias...

Attr('href') will give you whatever is contained in the href property. If you want the "http://otherpage.com"; then that needs to be contained in the href property. Using the 'domain' property of the document object will give
you the first part:

        <script type="text/javascript">
        <!--
                alert(document.domain);
        //-->
        </script>

andy

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery- [EMAIL PROTECTED] On

Behalf Of Matthias Coy
Sent: Friday, December 05, 2008 10:10 AM
To: jquery-en@googlegroups.com
Subject: [jQuery] How to access href-property

Hi there,

how do I access the "href"-property of an anchor-element? I know there is a

$("#idOfAnAnchor").attr("href");

but this only gives me the attribute and not the property. I need the property, because inside of this property is the full URL. See example:

<a id="idOfAnAnchor1" href="/index.php">Home</a> // on otherpage.com <a
id="idOfAnAnchor2" href="http://somepage.com/index.php";>Home</a>

$("#idOfAnAnchor1").attr("href"); // gives '/index.php', needed is
'http://otherpage.com/index.php'
$("#idOfAnAnchor2").attr("href"); // gives 'http://somepage.com/index.php'

I could use:

var aLink = document.getElementById("#idOfAnAnchor1");
var aHrefProperty = aLink.href;

but where is the jQuery fun in this :) ?

Regards
        Matthias

Reply via email to