• User

    [Risolto] Modificare link javascript

    Salve a tutti, ho un codice che mi visualizza le ultime 5 foto in miniatura da una galleria di flickr. Quando si clicca su una di queste miniatura si apre una specie di popup in javascript... io invece vorrei modificare il codice x fare in modo che quando si fa click su un img si apre il link www.sito.ext

    La demo è qui.

    Il codice del javascript è il seguente:

    fjb={
    
    // Properties to change
    
        pics:5,
        nextLabel:'Precedente',
        prevLabel:'Successiva',
        linkID:'flickrlink',
        largePicID:'flickrshot',
        navClass:'nav',
        loadingMessage:'Loading images...',
        fullImageLink:'See full image on flickr',
    
    // end properties, here be dragons
        
    ls:null,current:1,init:function(){fjb.srcLink=document.getElementById(fjb.linkID);if(!fjb.srcLink){return;}
    fjb.srcLink.innerHTML=fjb.loadingMessage;var furl=fjb.srcLink.href.replace(/.*photos\//,'');
    var url='http://flickr.com/services/feeds/photos_public.gne?id='+furl+'&format=json';
    var script=document.createElement('script');script.type = 'text/javascript';
    script.src=url;document.getElementsByTagName("head")[0].appendChild(script);},compute:function(obj){fjb.stream=document.createElement('ul');
    fjb.stream.id=fjb.linkID;var output='',temp='';for(i in obj.items){temp=obj.items*.description.match(/src="([^&]*)"/)[1];
    temp=temp.replace(/_m.jpg/g,'_s.jpg');
    output+='<li><a href="'+obj.items*.link + '" title="'+obj.items*.title + '" onclick="fjb.show(this);return false"><img src="' + temp+'" alt="'+obj.items*.title+'" /></a></li>';
    }var rep=fjb.srcLink.parentNode.nodeName.toLowerCase()==='p'?fjb.srcLink.parentNode:fjb.srcLink;rep.parentNode.replaceChild(fjb.stream,rep);
    fjb.stream.innerHTML=output;var prevlink='<li class="'+fjb.navClass+'"><a href="#" onclick="fjb.navigate(-1);return false">'+fjb.prevLabel+'</a></li>';
    fjb.stream.innerHTML=prevlink+fjb.stream.innerHTML;var nextlink='<li class="'+fjb.navClass+'"><a href="#" onclick="fjb.navigate(1);return false">'+fjb.nextLabel+'</a></li>';
    fjb.all=obj.items.length;
    fjb.stream.innerHTML+=nextlink;for(var i=1;i<=fjb.all-1;i++){fjb.stream.getElementsByTagName('li')*.style.display='none';
    }fjb.navigate(0);},navigate:function(offset){for(var i=1;i<=fjb.all;i++){fjb.stream.getElementsByTagName('li')*.style.display='none';
    }var change=fjb.pics*offset;fjb.current+=change;for(var i=fjb.current;i<fjb.current+fjb.pics;i++){if(fjb.stream.getElementsByTagName('li')*)
    {fjb.stream.getElementsByTagName('li')*.style.display='block';
    }}var fl=fjb.stream.getElementsByTagName('a')[0];fl.style.display=fjb.current==1?'none':'block';var ll=fjb.stream.getElementsByTagName('a')
    [fjb.all+1];ll.style.display=fjb.current>fjb.all-fjb.pics?'none':'block';},show:function(o){if(fjb.ls===null){fjb.ls=document.createElement('div');
    document.body.appendChild(fjb.ls);fjb.ls.id=fjb.largePicID;fjb.ls.style.position='absolute';
    } var prev='<p><a href="'+o.href+'">'+fjb.fullImageLink+'</a></p>';
    fjb.ls.innerHTML='<a href="#" onclick="this.parentNode.style.display=\'none\';this.parentNode.parent.focus();
    return false" class="fjbcloser">X</a><h4>'+o.title+'</h4><a href="#" onclick="this.parentNode.style.display=\'none\';this.parentNode.parent.focus();
    return false">'+o.innerHTML.replace(/_s.jpg/,'_m.jpg')+'</a>'+prev;fjb.ls.style.display='block';var y=0;if(self.pageYOffset){y=self.pageYOffset;}
     else if (document.documentElement && document.documentElement.scrollTop){y=document.documentElement.scrollTop;} else if
     (document.body){y=document.body.scrollTop;}fjb.ls.style.top=y+'px';fjb.ls.parent=o;fjb.ls.getElementsByTagName('a')[0].focus();
     },addLoadEvent:function(func){var oldonload = window.onload;if (typeof window.onload != 'function')
      {window.onload=func;}else{window.onload=function(){if(oldonload){oldonload();}func();}}}};function jsonFlickrFeed(obj){fjb.compute(obj);}fjb.addLoadEvent(fjb.init);
    
    

  • Super User

    Ciao 🙂

    Dovrebbe bastare modificare la parte in rosso dove ho impostato come sito google.

    fjb={

    // Properties to change

    pics:5,
    nextLabel:'Precedente',
    prevLabel:'Successiva',
    linkID:'flickrlink',
    largePicID:'flickrshot',
    navClass:'nav',
    loadingMessage:'Loading images...',
    fullImageLink:'See full image on flickr',
    

    // end properties, here be dragons

    ls:null,current:1,init:function(){fjb.srcLink=document.getElementById(fjb.linkID);if(!fjb.srcLink){return;}
    fjb.srcLink.innerHTML=fjb.loadingMessage;var furl=fjb.srcLink.href.replace(/.photos//,'');
    var url='http://flickr.com/services/feeds/photos_public.gne?id='+furl+'&format=json';
    var script=document.createElement('script');script.type = 'text/javascript';
    script.src=url;document.getElementsByTagName("head")[0].appendChild(script);},compute:function(obj){fjb.stream=document.createElement('ul');
    fjb.stream.id=fjb.linkID;var output='',temp='';for(i in obj.items){temp=obj.items
    .description.match(/src="([^&])"/)[1];
    temp=temp.replace(/_m.jpg/g,'_s.jpg');
    output+='<li><a href="http://www.google.com/" title="'+obj.items
    .title + '" onclick="fjb.show(this);return false"><img src="' + temp+'" alt="'+obj.items*.title+'" /></a></li>';
    }var rep=fjb.srcLink.parentNode.nodeName.toLowerCase()==='p'?fjb.srcLink.parentNode:fjb.srcLink;rep.parentNode.replaceChild(fjb.stream,rep);
    fjb.stream.innerHTML=output;var prevlink='<li class="'+fjb.navClass+'"><a href="#" onclick="fjb.navigate(-1);return false">'+fjb.prevLabel+'</a></li>';
    fjb.stream.innerHTML=prevlink+fjb.stream.innerHTML;var nextlink='<li class="'+fjb.navClass+'"><a href="#" onclick="fjb.navigate(1);return false">'+fjb.nextLabel+'</a></li>';
    fjb.all=obj.items.length;
    fjb.stream.innerHTML+=nextlink;for(var i=1;i<=fjb.all-1;i++){fjb.stream.getElementsByTagName('li').style.display='none';
    }fjb.navigate(0);},navigate:function(offset){for(var i=1;i<=fjb.all;i++){fjb.stream.getElementsByTagName('li')
    .style.display='none';
    }var change=fjb.picsoffset;fjb.current+=change;for(var i=fjb.current;i<fjb.current+fjb.pics;i++){if(fjb.stream.getElementsByTagName('li'))
    {fjb.stream.getElementsByTagName('li')*.style.display='block';
    }}var fl=fjb.stream.getElementsByTagName('a')[0];fl.style.display=fjb.current==1?'none':'block';var ll=fjb.stream.getElementsByTagName('a')
    [fjb.all+1];ll.style.display=fjb.current>fjb.all-fjb.pics?'none':'block';},show:function(o){if(fjb.ls===null){fjb.ls=document.createElement('div');
    document.body.appendChild(fjb.ls);fjb.ls.id=fjb.largePicID;fjb.ls.style.position='absolute';
    } var prev='<p><a href="'+o.href+'">'+fjb.fullImageLink+'</a></p>';
    fjb.ls.innerHTML='<a href="#" onclick="this.parentNode.style.display='none';this.parentNode.parent.focus();
    return false" class="fjbcloser">X</a><h4>'+o.title+'</h4><a href="#" onclick="this.parentNode.style.display='none';this.parentNode.parent.focus();
    return false">'+o.innerHTML.replace(/_s.jpg/,'_m.jpg')+'</a>'+prev;fjb.ls.style.display='block';var y=0;if(self.pageYOffset){y=self.pageYOffset;}
    else if (document.documentElement && document.documentElement.scrollTop){y=document.documentElement.scrollTop;} else if
    (document.body){y=document.body.scrollTop;}fjb.ls.style.top=y+'px';fjb.ls.parent=o;fjb.ls.getElementsByTagName('a')[0].focus();
    },addLoadEvent:function(func){var oldonload = window.onload;if (typeof window.onload != 'function')
    {window.onload=func;}else{window.onload=function(){if(oldonload){oldonload();}func();}}}};function jsonFlickrFeed(obj){fjb.compute(obj);}fjb.addLoadEvent(fjb.init);

    Visto al volo, non garantisco nulla 🙂 prova 😉

    :ciauz: