I have written a code ( => just for myself usage) that makes links
bookmarks like this example:

you are on : "http://www.mysite.com/index.php";
you click a link like "sitemap.php"
it will be load and you will see "http://www.mysite.com/
index.php#sitemap"

or if you click "myfile.php?id=3&p=test"
it load and you will see "http://www.mysite.com/index.php#myfile:id=6/
p=test/"
this code dosn't change any anchor href and i think this is why this
code is better than others for me ( for seo )


you can see the example on " http://www.giftcenter.ir "
and js file on : "http://www.giftcenter.ir/templates/Gift/js/js.js";

$(document).ready(function(){
                $("a").livequery('click',function(){
                                var h = $(this).attr("href");
                                 history(h);
                             $.get(h,function(){} );
               });

});

        var getHash = function(myHash){
                h = myHash;
                if ( h.length < 1) h = 'index';
                if ( h.indexOf(':') > 0 ){
                        h = h.replace(/^#/,'').replace(':','.php?');
                        while( h.indexOf('/') > 0 ) h = h.replace('/','&');
                }
                else { h = h.replace(/^#/,''); h += '.php'; }
                
$.get(h,{'ajax_check':'true'},function(data){$body.html('<center>' +
data + '</center>');});
                if($.browser.msie) _loadedHash =
_historyIframe.contentWindow.document.location.hash;
                else _loadedHash = myHash;

        };

        if ($.browser.msie) {
                var _historyIframe = $('<iframe style="display: none"></
iframe>').appendTo("BODY").get(0);
                var iframe = _historyIframe.contentWindow.document;
                iframe.open();
                iframe.close();
                setInterval(function(){
                        var h = 
_historyIframe.contentWindow.document.location.hash;
                        if ( (_loadedHash != null) &&  ( _loadedHash != h) )    
getHash(h);
                }, 500);
        } else if ($.browser.mozilla) {

                setInterval(function(){
                        if ( (_loadedHash != null) && ( _loadedHash != 
location.hash) )
getHash(location.hash);
                }, 500);
        }

        try{
                if(location.hash.length > 0 && !$.browser.msie)
                        getHash(location.hash);
        }catch(e){ alert(e.name + ' ' + e.message); }



        var history = function(path){
                var qmp = (path.indexOf('?') > 0 ) ? path.indexOf('?') + 1 :
path.length + 1;
                var lp = path.length;
                var fileNameP1 = path.indexOf('.php') + 1;
                var fileNameP2 = (qmp > 1) ? qmp-1 : path.length;
                var params = path.substring(qmp,lp);
                var newPath = '';

                var fileName = path.substring(  path.substring
(0,fileNameP2).lastIndexOf('/')+1 , fileNameP2 ).replace('.php','');
                if (params.length > 0 ){
                        var a = explodeArray(params,"&");

                        for (var i=0, j=a.length; i<j; i++)     newPath += a[i] 
+ '/';
                        newPath = '#' + fileName + ':' + newPath;
                } else {
                        newPath = '#' + fileName;
                }
                if ($.browser.msie) {
                        var iframe = _historyIframe.contentWindow.document;
            iframe.open();
            iframe.close();
            iframe.location.hash = newPath;
                }
                location.hash = newPath;
                _loadedHash = newPath;
        };



On Oct 26, 11:34 pm, Pedram <pedram...@gmail.com> wrote:
> Dear Folks,
>  consider we have page A which has 4 links we filter these Links with
> javascipt History Plugin which we have, as you can see in below
> now Our History Plugin Works and it is Bookmarkable and everything is
> Ok right now,
> now consider each of these Links Do some Ajax Calls and Load Page B,
> so we have to give these links the ability to be bookmarkable and
> support History , so What I did is in to solve this problem , I used
> Livequery plugin , so I added 1,2...link to it
> and then Imported the History on it , but what accually happend ,Page
> I'm working in Page A Links there is no Problem , but when I start to
> click on the Page B links ,
> You know I could not get back , so page B history works for Page B
> links , And Page A history works in Page A Links ,
> I think at the first because Page B is not Loaded to the System , It
> can not realize what it is in it , so ...
> this happens , I don't know what exactly to do , Just I want  to make
> Dynamic Portal with History support , Dear Karl,Mike Alsup, Jorn ...
> guys Help ...
> <!-------------------------------Page A
> -------------------------------
>
> <div>
>   <a href='#1'  id='1'>1</a>
>   <a href='#2'  id='2'>2</a>
>   <a href='#3'  id='3'>3</a>
>   <a href='#4'  id='4'>4</a>
>   <div id=''load> Ajax Contenct Comes here</div>
> </div>
> <!-------------------------------Page B
> -------------------------------
>
> <div>
>   <a href='#5' id='5' >5</a>
>   <a href='#6' id='6' >6</a>
>   <a href='#7' id='7' >7</a>
>   <a href='#8' id='8' >8</a>
> </div>
>
> <!-----------------Script ----------------------------------------->
>
> $(document).ready(function(){
>
>   $("#1,#2,#3,#4,#5,#6,#7,#8").livequery(function(){
>      $(this).history(function() {   alert($ (this).attr(''id));  $
> (this).load('pageb.php') });
>   });
>   $.ajaxHistory.initialize();
>
> });
>
> Regards Pedram
> .

Reply via email to