Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Java
  4. I have problem with bookmark(Javascript) in opera.It works in other browser.

I have problem with bookmark(Javascript) in opera.It works in other browser.

Scheduled Pinned Locked Moved Java
helpjavascriptsysadminquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bhatted
    wrote on last edited by
    #1

    HI, I am using Javascript for bookmark in my project.Here is the code function prepBookmarkLink() { if (window.sidebar && window.opera && window.print) { var bkmkLink = document.getElementById('bookmarkLink'); // bkmkLink.rel = 'sidebar'; // bkmkLink.href = location.href; // bkmkLink.title = document.title; // bkmkLink.setAttribute('href',document.URL); // bkmkLink.setAttribute('title',document.title); // bkmkLink.setAttribute('rel','sidebar'); // bkmkLink.click(); } } function bookmark(){ var title = document.title; var url= document.URL; var ua=navigator.userAgent.toLowerCase(); var isKonq=(ua.indexOf('konqueror')!=-1); var isSafari=(ua.indexOf('webkit')!=-1); var isMac=(ua.indexOf('mac')!=-1); var buttonStr=isMac?'Command/Cmd':'CTRL'; if(window.sidebar){ window.sidebar.addPanel(title,url,""); } else if(window.opera && window.print) { prepBookmarkLink(); // (document.write('[Add Bookmark](javascript:bookmark())')); var elem = document.createElement('a'); elem.setAttribute('href',url); elem.setAttribute('title',title); elem.setAttribute('rel','sidebar'); elem.click(); // var a=document.createElement('a'); // a.href=location.href; // // // a.rel='sidebar'; // this makes it work in Opera 7+ // a.click(); // // a.title=document.title; // return cont.appendChild(a); // // document.write('Bookmark Site'); alert('test'); } else if(window.external && (!document.createTextNode || (typeof(window.external.AddFavorite)=='unknown'))) { // IE4/Win generates an error when you // execute "typeof(window.external.AddFavorite)" // In IE7 the page must be from a web server, not directly from a local // file system, otherwise, you will get a permission denied error. window.external.AddFavorite(url, title); // IE/Win } else if(isKonq) { alert('You need to press CTRL + B to bookmark our site.'); } else if(window.opera) { alert("dfsdf"); void(0); // do nothing here (Opera 7+) //return true; } else if(window.home || isSafari) { // Firefox, Netscape, Safari, iCab alert('You need to press '+buttonStr+' + D to bookmark our site.'); } else if(!window.print || isMac) { // IE5/Mac and Safari 1.0 alert('You

    T 1 Reply Last reply
    0
    • B bhatted

      HI, I am using Javascript for bookmark in my project.Here is the code function prepBookmarkLink() { if (window.sidebar && window.opera && window.print) { var bkmkLink = document.getElementById('bookmarkLink'); // bkmkLink.rel = 'sidebar'; // bkmkLink.href = location.href; // bkmkLink.title = document.title; // bkmkLink.setAttribute('href',document.URL); // bkmkLink.setAttribute('title',document.title); // bkmkLink.setAttribute('rel','sidebar'); // bkmkLink.click(); } } function bookmark(){ var title = document.title; var url= document.URL; var ua=navigator.userAgent.toLowerCase(); var isKonq=(ua.indexOf('konqueror')!=-1); var isSafari=(ua.indexOf('webkit')!=-1); var isMac=(ua.indexOf('mac')!=-1); var buttonStr=isMac?'Command/Cmd':'CTRL'; if(window.sidebar){ window.sidebar.addPanel(title,url,""); } else if(window.opera && window.print) { prepBookmarkLink(); // (document.write('[Add Bookmark](javascript:bookmark())')); var elem = document.createElement('a'); elem.setAttribute('href',url); elem.setAttribute('title',title); elem.setAttribute('rel','sidebar'); elem.click(); // var a=document.createElement('a'); // a.href=location.href; // // // a.rel='sidebar'; // this makes it work in Opera 7+ // a.click(); // // a.title=document.title; // return cont.appendChild(a); // // document.write('Bookmark Site'); alert('test'); } else if(window.external && (!document.createTextNode || (typeof(window.external.AddFavorite)=='unknown'))) { // IE4/Win generates an error when you // execute "typeof(window.external.AddFavorite)" // In IE7 the page must be from a web server, not directly from a local // file system, otherwise, you will get a permission denied error. window.external.AddFavorite(url, title); // IE/Win } else if(isKonq) { alert('You need to press CTRL + B to bookmark our site.'); } else if(window.opera) { alert("dfsdf"); void(0); // do nothing here (Opera 7+) //return true; } else if(window.home || isSafari) { // Firefox, Netscape, Safari, iCab alert('You need to press '+buttonStr+' + D to bookmark our site.'); } else if(!window.print || isMac) { // IE5/Mac and Safari 1.0 alert('You

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2
      1. you don't follow the posting guidelines and the messages formatting rules. 2) this is not Java, it is Javascript, so ask the right forum if you want to get relevant answers about this. Also, I'm sure google knows plenty of cross-browsers working solutions

      [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups