Jump to content

Bookmark of Permanent Link not stable


Recommended Posts

  • 1 month later...

Are you using Google Chrome?

Chrome doesn´t allow javascript bookmarks.

 

Prestashop uses a javascript function to write the link to add a bookmark that works different depending the "User-agent" of the navigator. When google chrome is detected the js function does not write anything.

 

 

 

function writeBookmarkLinkObject(url, title, insert)
{
if (window.navigator.userAgent.indexOf('Chrome') != -1)
	return ('');
else if (window.sidebar || window.external)
	return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + escape(title) + '\')">' + insert + '</a>');
else if (window.opera && window.print)
	return ('<a rel="sidebar" href="' + escape(url) + '" title="' + escape(title) + '">' + insert + '</a>');
return ('');

 

If you prefer can add a link only for chrome to show the alternative method to javascript bookmarks. For ex. "CTRL+D" instructions.

Edited by prescol (see edit history)
Link to comment
Share on other sites

This modify is guaranteed for version 1.4.3. Older & Newer versions please test.

 

You can modify tools.js and add the following code to get a cute "howto" advise.

 

{Prestashopdir}/js/Tools.js

 

Default code:

function writeBookmarkLinkObject(url, title, insert)
{
if (window.navigator.userAgent.indexOf('Chrome') != -1)
	return ('');
else if (window.sidebar || window.external)
	return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + escape(title) + '\')">' + insert + '</a>');
else if (window.opera && window.print)
	return ('<a rel="sidebar" href="' + escape(url) + '" title="' + escape(title) + '">' + insert + '</a>');
return ('');
}

 

Replace

return ('');

with this:

return ('<a href="#" class="bookmark_xenon">'+ insert +'<span>Press "Ctrl + D" to add to favorites</span></a>');

 

 

New code:

function writeBookmarkLinkObject(url, title, insert)
{
if (window.navigator.userAgent.indexOf('Chrome') != -1)
	return ('<a href="#" class="bookmark_xenon">'+ insert +'<span>Press "Ctrl + D" to add to favorites</span></a>');
else if (window.sidebar || window.external)
	return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + escape(title) + '\')">' + insert + '</a>');
else if (window.opera && window.print)
	return ('<a rel="sidebar" href="' + escape(url) + '" title="' + escape(title) + '">' + insert + '</a>');
return ('');
}

 

Now we should add a few lines to blockpermanentlinks.css

 

Add this at the end of the file:

.bookmark_xenon span {
width:80px;
padding:5px;
background:#FFC;
color:#666;
box-shadow:1px 1px 2px #ccc;
position:absolute;
/* Modify this depending your template design*/
top:15px;
z-index:999;
display:none
}
.bookmark_xenon:hover span { display:block}

 

 

View the attached file to see the result.post-279358-0-21198300-1313316265_thumb.jpg

  • Like 1
Link to comment
Share on other sites

  • 4 months later...

Hi, actually my code under "Write bookmark link object" is different from what you attached. Mine reads

 

if (window.sidebar || window.external)

return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + escape(title) + '\')">' + insert + '</a>');

else if (window.opera && window.print)

return ('<a rel="sidebar" href="' + escape(url) + '" title="' + escape(title) + '">' + insert + '</a>');

return ('');

 

Where would I insert the code that you were telling me about? Thanks

Link to comment
Share on other sites

  • 2 weeks later...

Hi, actually my code under "Write bookmark link object" is different from what you attached. Mine reads

 

if (window.sidebar || window.external)

return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + escape(title) + '\')">' + insert + '</a>');

else if (window.opera && window.print)

return ('<a rel="sidebar" href="' + escape(url) + '" title="' + escape(title) + '">' + insert + '</a>');

return ('');

 

Where would I insert the code that you were telling me about? Thanks

What is your version of prestashop?

Link to comment
Share on other sites

×
×
  • Create New...