Jeg oplever et (Stort) problem med konvertering af danske spacial karakter (æøå) i Safari Browseren.
Jeg anvender
denne jQuery BreadCrumb, som vieker HELT efter hensigten i alle browsere - undtagen Safari - problemet er at hvis der er æ,ø,å i querystringen "
demo.html?t=JCrumb-æ-Page-1" stopper udskrivningen af querystringen, dvs.
var querystring = "t";
document.write(t);
bliver til:
JCrumb-<---
hvor bliver resten af?og ikke
JCrumb-æ-Page-1 som det er meningen...
demo.html:
- <!DOCTYPE html>
- <html>
- <head>
- <title>JCrumb - Instant Breadcrumbs</title>
- <link type="text/css" href="css/ui-lightness/jquery-ui-1.8.5.custom.css" rel="stylesheet" />
- <link href="css/styles.css" media="all" rel="stylesheet" type="text/css" />
- <link href="css/jCrumb.css" media="all" rel="stylesheet" type="text/css" />
- <link href="css/jCrumbGray.css" media="all" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="content">
- <h1>JCrumb - Instant Breadcrumbs Demo Usage</h1>
- <p>Version 1.0 - <a href="mailto:loktar69@hotmail.com" title="Support Email">Support Contact</a></p>
- <h2>Must be run through with a web server for cookies to be generated to save breadcrumbs</h2>
- <p>First click the site links in order to get some breadcrumbs generated</p>
- <ul>
- <li><a href="demo.html?t=JCrumb-Main">breadcrumbs</a> </li>
- <li><a href="demo.html?t=JCrumb-æ-Page-1">Page 1</a></li>
- <li><a href="demo.html?t=JCrumb-ø-Page-2">Page 2</a></li>
- <li><a href="demo.html?t=JCrumb-å-Page-3">Page 3</a></li>
- </ul>
-
- <div id="basic"></div>
-
- </div>
-
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script>
- <script type="text/javascript" src="jquery.jcrumb.js" charset="utf-8"></script>
- <script type="text/javascript">
- $(document).ready(function(){
- // change the title just to simulate different pages
- var title = "[\\?&]t=([^&#]*)",
- regex = new RegExp(title),
- result = regex.exec( unescape(window.location.href) );
-
- if(result){
- $('title').text(decodeURIComponent(result[1]));
- }
- else{
- $('title').text("JCrumb Main");
- }
-
- // jCrumb initialization and useage
- $('#basic').jCrumb({maxCrumbs:4});
-
- });
- </script>
- </body>
- </html>
jquery.jcrumb.js:
- (function($){
- $.fn.jCrumb = function(options) {
- var settings = {
- maxCrumbs : 4,
- maxMemory : 15,
- defaultClass : 'jCrumb',
- jqUI : false,
- seperator : ">"
- },
- getCrumbs = function(){
- var cookieName = "breadcrumbs=",
- cookies = document.cookie.split(';');
-
- for(var i=0;i < cookies.length;i++) {
- var cookie = cookies[i].replace(/^\s+/,"");
-
- if (cookie.indexOf(cookieName) == 0){
- return cookie.substring(cookieName.length,cookie.length);
- }
- }
- return;
- },
- setCrumb = function(crumb){
- var crumbs = getCrumbs();
-
- if(crumbs){
- var maxMemory = settings.maxMemory;
- crumbCheck = crumbs.split('*');
-
- if(crumbCheck[crumbCheck.length-1] != crumb){
- crumbCheck.push(crumb);
- }
-
- if(crumbCheck.length > maxMemory){
- crumbCheck.splice(0,1);
- }
-
- crumbs = crumbCheck.join('*');
- }else{
- crumbs = crumb;
- }
-
- document.cookie = 'breadcrumbs=' + crumbs +'; path=/';
- },
- removeCrumb = function(crumb, index){
- var crumbs = getCrumbs();
- if(crumbs){
- crumbCheck = crumbs.split('*');
- crumbCheck.splice(index,(crumbCheck.length - index));
- crumbs = crumbCheck.join('*');
- document.cookie = 'breadcrumbs=' + crumbs +'; path=/';
- }
-
- return;
- };
- return this.each(function() {
-
- if (options) {
- settings = $.extend(settings, options);
- }
-
- setCrumb(document.title + '^' + window.location.href);
-
- var crumbs = getCrumbs(),
- crumbVal = "",
- crumbList = $(document.createElement('ul')).addClass(settings.defaultClass).appendTo($(this)),
- crumbListItem = "";
-
- if(settings.jqUI){
- crumbList.addClass('fg-buttonset fg-buttonset-single ui-helper-clearfix');
- }
-
- if(crumbs){
- crumbs = crumbs.split('*');
- startIndex = 0;
-
- if(crumbs.length > settings.maxCrumbs){
- startIndex = crumbs.length - settings.maxCrumbs;
- }
-
- for(var i = startIndex; i < crumbs.length-1;i++){
- crumbVal = crumbs[i].split('^');
- crumbListItem = $(document.createElement('li'));
-
- var crumbLink = $(document.createElement('a'));
- crumbLink.attr({'href' : crumbVal[1]}).text(crumbVal[0]).appendTo(crumbListItem.appendTo(crumbList));
- crumbLink.click(function(){removeCrumb($(this).text() + '^'+ $(this).attr('href'), $(this).data("index"));});
- crumbLink.data("index", i);
-
- if(settings.jqUI){
- crumbListItem.addClass('fg-button ui-state-default ui-priority-primary');
- if(i === 0){
- crumbListItem.addClass('ui-corner-left');
- crumbLink.addClass('ui-icon ui-icon-home');
- }
- if(startIndex !== 0 && i === startIndex){
- crumbListItem.addClass('ui-corner-left');
- crumbLink.addClass('ui-icon ui-icon-carat-1-w');
- }
- }else if(settings.seperator){
- $(document.createElement('span')).html(settings.seperator).appendTo(crumbListItem);
- }
- }
-
- crumbListItem = $(document.createElement('li'));
- crumbVal = crumbs[crumbs.length-1].split('^');
- $(document.createElement('span')).text(crumbVal[0]).appendTo($(crumbListItem).appendTo($(crumbList)));
-
- if(settings.jqUI){
- crumbListItem.addClass('fg-button ui-state-default ui-priority-primary ui-corner-right ui-state-active');
- }
-
- $(".fg-button:not(.ui-state-disabled)").hover(
- function(){
- $(this).addClass("ui-state-hover");
- },
- function(){
- $(this).removeClass("ui-state-hover");
- }
- )
- }
- });
- };
- })(jQuery);