0

I have a question about retrofitting the following code to gracefully handle noscript scenario.

Call me <a href="" onclick="activateContact(); return false;" unselectable="on"> <span>My Contact</span> </a>

I'd like to subsitute the line above in case of noscript with:

Call me at 1-800-555-1525. 

Thanks in advace.

4

2 回答 2

2

Set the link to noscript behavior:

 Call me at <a  id="callMeLink" href="#" unselectable="on"> <span>1-800-555-1525.</span> </a>

Then do the progressive enhancement with js. If the js is not activated in browser, the link above will be on the right format already.

<script>
   var callMeLink = document.getElementById("callMeLink");
   callMeLink.onclick = activeContact;
   callMeLink.innerHTML = "<span>My Contact</span>";
</script>
于 2012-08-14T17:43:20.170 回答
1

script tag is used for javaScript. Same way there is tag which gets in action when the Javascript is diabled in browser. So to substitute your anchor with noscript data when JS is disbaled in browser. Use this

<script>
  Call me <a href="" onclick="activateContact(); return false;" unselectable="on"> 
  <span>My Contact</span> </a>
</script>


<noscript>
    Call me at 1-800-555-1525. 
</noscript>
于 2012-08-14T17:43:38.820 回答