Anchor Tags
Linking to the Same Page

The destination anchor label is placed where you want to go, and the hyperlink is placed where you want to click from. The links can appear before or after the destination. Links are case-sensitive, so be careful to use exactly the same capitalization in the link as in the destination anchor codes. In the example below "terms" and "Terms" may not match up in the newer browsers.

Here is the anchor label used in a snippet of code:
<a name="terms">Payment Options</a>

And here is the hyperlink code to go there:
See my <a href="#terms">payment</a> details.

If you want to link to a specific location on another page, put the anchor label on that page and then link to it with code like this:
Visit my <a href="http://www.myhost.com/mypage.htm#terms">terms</a> page.




You've added the anchor tag to your listing so that users can click to go to your terms at the bottom of the page. But now it won't work in your eBay auction. There may be two very different issues at work here.


Relative or Local (Anchor) Link issues in eBay's Editor

Using eBay's enhanced online what-you-see-is-what-you-get (WYSIWYG) description editor when listing, ANY editing (even just a mouse click), anywhere in your description, will send your code through the browser's code rewriter.

HREF links will be redefined based on the following prefix styles:
  • Single letter prefix (H:) creates a file link (file:///H:)
  • Two or more letters (HT: or HTTP:) are left alone
  • Empty links (href="") are left alone
  • Relative links (/link.htm), and malformed links missing the letter(s) and colon, are prefixed with the root URL of eBay's current page.
  • Local page links (#bookmark), and undefined links ("#"), are prefixed with the current page URL. If you are in the initial editing screen, the added URL will be short. If you have returned to the editor from the final preview page, the added URL will be very long. Whatever is in the address line of your browser will be the prefix.

There doesn't seem to be any easy way around this except to avoid touching eBay's enhanced editor after adding relative links to your code.

If you need to use the enhanced editor, then one workaround is to script the link that could get rewritten. This is an example:
<script language=javascript>document.write( '<a href="#terms">click here</a>' )</script>

Relative or Local (Anchor) Link in eBay's Listing iframes

eBay will often display the listing, on first visit, in a frameless page. Your description is simply an extension of eBay's content. However, on second visit, eBay may place your description in its own iframe, nested in another iframe that is nested in eBay's page. This three-layer-deep presentation provides security for eBay's content and prevents eBay's styles from interfering with your content.

But, for security reasons, many browsers no longer support anchors that are nested that many layers deep. So you may find your menus and local anchors working in some browsers and not others, and on first visit while not on later visits. You many want to redesign your page to use a different approach. If you can't, this script can be added to the bottom of your page to get your links working again in most situations.

<script type="text/javascript" >
function iframeAnchorBlur(el){
  setTimeout("document.getElementById('"+el.id+"').blur()",100);
}
function iframeAnchors() {
  if (document.getElementsByTagName) {
    var inp1='type="image" ';
    var inp2='src="http://pics.ebaystatic.com/aw/pics/s.gif" ';
    var inp3='style="position:relative;width:1px;height:1px;'
      +'border:0px;margin:0px;padding:0px;left:0px;'
      +'text-decoration:none;font-size:0px;';
    var allLinks = document.getElementsByTagName("a");
    for (var i=0;i<allLinks.length;i++) {
      if( allLinks[i].href){
        var aLink = allLinks[i];
        if (aLink.href.indexOf('#')>-1){
          var dest=aLink.href.split('#')[1];
          aLink.onclick=new Function("document.getElementById('iA"
	    +dest+"').focus();return false;");
        }
      }
      if (allLinks[i].name) {
        var aLink = allLinks[i];
        newAnchor=document.createElement('span');
        newAnchor.style.position='relative';
        newAnchor.style.width="1px";
        newAnchor.style.height="1px";
        newAnchor.innerHTML='<input id="aA'+aLink.name+'" '
          +'onfocus="iframeAnchorBlur(this)" '
          +inp1+inp2+inp3+'top:-100px;">'
          +'<input id="iA'+aLink.name+'" '
          +'onfocus="document.getElementById(\'aA'
		+aLink.name+'\').focus()" '
          +inp1+inp2+inp3+'top:100px;">';
        aLink.insertBefore(newAnchor,aLink.firstChild);
      }
    }
  }
}
if (window.top!=window.self) {iframeAnchors();}
</script>
© 2006-2012 Shipscript