문제

I´m trying to add nofollow to a link with an existing rel attribute that triggers an iframe popup.

Here is the link I am trying to alter:

<a class="modal" rel="{handler: 'iframe', size: {x: 700, y: 550}}" 
title="Email" href="/myurl.html">link text...</a>

The question is, how do I add nofollow to the rel attribute without messing up the popup?

I have tried this, but it comprimizes the popup release:

<a class="modal" rel="nofollow {handler: 'iframe', size: {x: 700, y: 550}}" 
title="Email" href="/myurl.html">link text...</a>
도움이 되었습니까?

해결책

you can try having the links with rel="nofollow" so search engines can read it, and then you can change that value onclick. like this

<a id="mylink" rel="nofollow" onclick="return changerel(this);" href="#">link</a>

<script type="text/javascript">
function changerel(el)
{
    var myreplace = "{handler: 'iframe', size: {x: 700, y: 550}}";

    alert('rel before:'+el.rel)

    el.setAttribute("rel", myreplace);

    alert('rel after:'+el.rel);

    if (el.rel != myreplace)
    {
         el.onclick();   
    }
}
</script>

see it in action here http://jsfiddle.net/5Basb/4/

다른 팁

Having a JavaScript object in the rel attribute is non-standard, so is nofollow. However, the nofollow attribute value would comply with valid link types. What library or environment uses the information in your rel attribute? You could store it in a data attribute, so the rel can be used for its original intent.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top