Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add quotation marks for Internet Explorer

    The <q> element is for inline quotations, and the specs very clearly say that user-agents should add quotation marks around the text inside a <q>, and that authors therefore must not add quotation marks themselves.

    Trouble is, Windows IE doesn't do it ... but if you add them yourself not only do you violate the spec, but conforming user agents end up with two sets of marks. And if you abandon <q> in favour of <i> then you've lost valuable semantics.

    So what do you do? You use them properly and have this do the work for you - it iterates through <q> elements and adds quotation marks for Windows IE
    Code:
    ///global object
    var bc = new Object;
    
    //user agent
    bc.agt = navigator.userAgent.toLowerCase();
    
    //onload function
    window.onload = function()
    {
    	//iterate through <q> elements and add quotation marks for win/ie
    	if(
    		typeof document.all !="undefined" 
    		&& typeof window.opera == "undefined" 
    		&& bc.agt.indexOf('win') != -1
    		)
    	{
    		bc.quotes = document.getElementsByTagName('q');
    		bc.quotesLen = bc.quotes.length;
    		for(var i=0; i<bc.quotesLen; i++)
    		{
    			bc.qText = bc.quotes[i].innerText;
    			bc.quotes[i].innerHTML = '&quot;' + bc.qText + '&quot;';
    		}
    	}
    
    }
    Last edited by brothercake; 08-18-2003 at 03:06 AM.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •