Results 1 to 2 of 2

Thread: Bookmark Site Script not working in Opera

  1. #1
    Join Date
    Dec 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Bookmark Site Script not working in Opera

    Script Title: Bookmark Site

    URL: http://www.dynamicdrive.com/dynamicindex9/addbook.htm

    The current release of Opera will not add a bookmark from this script. I understand that this issue applies to Opera 7+ which blocks programmed clicks.

    The workaround is to write the links in Javascript, and write one for Opera with embedded links to create the bookmark:

    Code:
    <script type="text/javascript">
    var sidebarurl = "http://www.jesus.org.uk/sidebar.htm"; // Change as required
    var sidebartitle = "Jesus Army pages"; // Change as required
    var url = this.location;
    var title = document.title;
    
    function bookmarksite() {
    	if (window.sidebar && window.sidebar.addPanel){ // Firefox 
    		window.sidebar.addPanel(sidebartitle, sidebarurl,"");
    	} 
    	else if ( document.all ) { // IE Favorite
    		window.external.AddFavorite(url, title); 
    	}
    	else if (window.opera && window.print) {
    		// do nothing
     }
    	else if (navigator.appName=="Netscape") {
    		alert("Please click OK, then press <Ctrl-D> to bookmark this page.");
    	}
     }
    
     if (window.sidebar && window.sidebar.addPanel) {
      document.write('<a href = "javascript:bookmarksite();">Bookmark Site</a>');
      }
     else if (document.all) {
      document.write('<a href = "javascript:bookmarksite();">Add to Favourites</a>');
     }
     else if (window.opera && window.print) {
    	 document.write('<a href = "'+sidebarurl+'" title="'+sidebartitle+'" rel="sidebar">Bookmark Site</a>');
     }
     else if (navigator.appName=="Netscape") {
      document.write('<a href = "javascript:bookmarksite();">Bookmark this page</a>');
    }
     </script>
    This script can just be put in the body of the page where the bookmark link is required.

    Opera and Firefox put a bookmark in the sidepanel. For this the best idea is a specific mini page that gives a selection of links for your site, and which has a line <base target=_content> in the head section of the page so that clicks on the mini page will open in the main page of the browser
    Last edited by jesusarmy; 12-11-2008 at 04:18 PM. Reason: More haste, less speed. Code now operational at http://www.jesus.org.uk/ja

  2. #2
    Join Date
    Dec 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    There may be some difficulty getting this to work inside a frameset. This version overcomes that problem. As before, any apostrophes in the title need to be escaped with backslashes.

    Code:
    <script type="text/javascript">
    sidebarurl = "http://www.jesus.org.uk/sidebar.htm"; // Change as required
    sidebartitle = "Jesus Army pages"; // Change as required
    
    if (window.sidebar && window.sidebar.addPanel) {
       document.write('<a href = "#" onClick="window.sidebar.addPanel(\''+sidebartitle+'\', \''+sidebarurl+'\',\'\');return false;">Bookmark Site</a>');
       }
    
    else if (document.all) {
       document.write('<a href = "#" onClick="window.external.AddFavorite(location.href, document.title);return false;">Add to Favorites</a>');
       }
    
    else if (window.opera && window.print) {
       document.write('<a href = "'+sidebarurl+'" title="'+sidebartitle+'" rel="sidebar">Bookmark Site</a>');
       }
    
    else if (navigator.appName=="Netscape") {
       document.write('<a href = "#" onClick="alert(\'Please click OK, then press <Ctrl-D> to bookmark this page.\');return false;">Bookmark this page</a>');
       }
    </script>
    Google Chrome seems to think it is a Netscape browser in this code, and works OK.

Bookmarks

Posting Permissions

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