Announcement

Collapse
No announcement yet.

Automatic Superscript of ® Symbol

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Automatic Superscript of ® Symbol

    Hi all, one of my sites uses the ® symbol a lot and has to in order to keep it compliant, on some areas I have just wrapped the symbol in the <sup></sup> tags, but as it's used a lot this would be a nightmare to keep up with.

    I dont suppose anyone has any idea if this could be done automatically when the ® is found on a page? bit of a long shot I know but thought it worth a post!
    Many Thanks
    Lee
    www.mdnsupplies.co.uk
    www.hookandloopfasteners.co.uk

    #2
    With thanks to someone else I have got so far with this but Sellerdeck hates it and crashes as soon as the script is put in, though with a restart and preview it works, unfortunately if I then go into the design tab I get thrown out, this must be something to do with other scripts running, but way out of my understanding.

    The script I am using and that works is:

    <script type="text/javascript">
    $(document).ready(function() {
    $("body").html(

    $("body").html().replace(/&reg;/gi, '<sup>&reg;</sup>').replace(/®/gi, '<sup>&reg;</sup>')
    );
    });
    </script>

    If anyone has a mo I would be grateful if you could take a look.

    Cheers, Lee
    Many Thanks
    Lee
    www.mdnsupplies.co.uk
    www.hookandloopfasteners.co.uk

    Comment


      #3
      Replacing the entire BODY of a page on the fly will definitely break things.

      Far better to only process areas of text where these tags might occur.
      The below will only process code within tags containing classes product-text or supertext (and will not process anything within class notsuper). So add class supertext to tags that are likely to contain this char. Or wrap <span class="supertext"> ... </span> around such areas.
      Code:
      <script type="text/javascript">
      $(document).ready(function() {
      	$('.product-text,.supertext').not('.notsuper').each(function(idx){
      		$(this).html($(this).html().replace(/&reg;/gi, '<sup>&reg;</sup>').replace(/®/gi, '<sup>&reg;</sup>'));
      		});
      	});
      </script>
      N.B. Untested, and you may need to add code to make sure it doesn't process bits where you've already put in the embedded HTML <sup>...</sup> stuff.
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #4
        Thanks Norman, works like a charm
        Many Thanks
        Lee
        www.mdnsupplies.co.uk
        www.hookandloopfasteners.co.uk

        Comment


          #5
          Thought it might. The line that does the heavy lifting:
          Code:
          $('.product-text,.supertext').not('.notsuper').each(function(idx)
          was lifted from an experimental version of my Tabbed Descriptions that scans the page looking for the {TAB NAME} stuff that introduces tabs.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment

          Working...
          X