Create a Bookmark link that works in Safari - javascript

I have tried using JavaScript "AddFavorite" function in my code, but it does not work in Safari. It works in IE, I think I remember Firefox, but nothing I have tried seems to work in Safari. All I want to do is have a link on my website that people can click on and it automatically creates a bookmark in their bookmarks folder/bookmark bar.
Does this entail Applescript or something like it? Or a deeper programming language I am unaware of?
<a href="javascript:bookmarksite('Name', 'website.com')">

From the apple forums: forum-link
On the Mac side at least, Safari does not allow a website to add a
bookmark. I'm pretty sure the same behaviour is in the Windows version
as well.

I've been down this road, and what I discovered was that Safari does NOT allow bookmarks to be made with JavaScript:
Apple Forum
bytes forum
They consider it unsafe. As frustrating as this is, I get their point.

Unfortunately, most things like this tend to be browser-specific, and picky.
my JS is about level 0, but i did find this on an old article here:
One specifically for Chrome:
Add to favourites link for Google Chrome
And another on a cross-browser bookmark link:
Cross-browser bookmark/add to favorites javascript
Hope between the previous comment and these links, you get what you needed.

Chrome and Safari does not allow it for clear security reason.
You could usee a script like this:
http://www.dynamicsitesolutions.com/javascript/add-bookmark-script/
which handles many browser and has a nice fallback: show a browser customized alert with instructuion message.
Es: in chrome it says: "Ctrl+D to add as bookmark"

In IE something similar to the following would work: (MSDN)
window.external.AddFavorite(location.href, document.title);
However, this won't work in other browsers. In Firefox, I believe you can use
window.sidebar.addPanel(document.title, location.href, '');
to create a sidebar panel (not a real bookmark) but as far as I know Chrome and Safari do not allow Javascript to automatically create bookmarks. For those, I recommend giving the user the instructions to do it manually:
drag a link to their bookmarks
pressing Ctrl + D to add a bookmark
Clicking + or star icon in the toolbar

Related

Website not working in Firefox/Chrome, but does in IE

There is a website that I must use at work quite a bit and the only browser it works on is Internet Explorer.
I'm presuming this is because the code is outdated/incorrect and includes javascript that only IE is able to read.
This is a problem, because I want to use Firefox or Chrome, they are much better browsers.
I believe the issue is Firefox/Chrome (hereinafter referred to as foam) not being able to recognize the following "onclick" command lines. When I press these buttons, the web page does not change as it should.
<button class="MenuButton" title="Create ICL" value="ADDICL" onclick="PageJump('ICLMain.asp?From=ICLHome')">Create ICL
So.... since this is not my website, I cannot re-write all of this code to fix it. It is a corporate owned underwriter website for creating a certain document.
There must be some sort of extension that enables Firefox/Chrome to read Javascript codes like Internet Explorer so that I can use Firefox/Chrome and still use this website.
Try to use chrome extension ie tab, https://chrome.google.com/webstore/detail/ie-tab/hehijbfgiekmjfkfjpbkbammjbdenadd?hl=es. This extension emulate The ie Explorer.
I'm also facing the same problem(Javascript broke). The solution I found is to just add https:// before the link and reload the page and everything will work fine again.

chrome extensions: full width toolbars

Im currently working on a fork of the famous web developer extension (chrome, firefox, opera). Exactly I am working on the chrome extension.
The Firefox extension is shown like that:
Chrome instead shows only a icon...
..which toggles the "pretty small" widget:
A part of my goal with this fork is to change this toggle icon to a toolbar such as firefox does.
After studying the documentation chrome extensions (https://developer.chrome.com/extensions/devguide) I came to the result that this is not possible with default settings (browser actions, page actions,...).
When I looked again at the Table of Contents in the documentation I got an idea. There is the possibility to edit the bookmarks. So it could be possible to add an additional bookmark bar/row and place the single web developer actions as bookmark with the function on it.
Is this the right way for solving this? Because at the moment I only see possibilities with more or less dirty hacks. And doing it via bookmarks seems at least dirty.
PS: I also thought about this:
The plugin is actually the same on firefox and chrome and from the same author. So when this adaption of the toolbar in chrome would be easy possible then would not have such differences in the chrome and firefox addon.
Nope, that's simply impossible.
Chrome does not support custom toolbars, and that includes "an additional bookmark bar/row".
The closest, visually, would be injecting UI directly into the top of all pages. I don't think I need to explain why that is hacky.

Trouble loading Firebug Lite in IE

I have downloaded the latest firebug-lite and placed it in my local directory and I am including it <script type="text/javascript" src="../js/firebug-lite.js"></script> just like that. IE is throwing this error in the console - SCRIPT5: Access is denied.
It seems like it's a cross-domain issue for IE, which I am not sure how it is - I do want to try to get it working in this specific way(local file) - the other ways to include it do work somewhat.
As far as the error Access is denied. is concerned, It is obvious that you are trying to run a script for which you don't have privileges. Are you the administrator of this PC, Are you using the limited or guest account while browsing using IE.
Nontheless, you can always follow these steps by Colin Pickard to get it working in IE
Go to some Firebug Lite page (http://getfirebug.com/firebuglite).
Click the "add to Favorites Bar" button on the Favorites Bar.
This will give you a bookmark to http://getfirebug.com/firebuglite.
Right click on the "Firebug Lite" link and choose "Copy Shortcut".
Right click on your new bookmark and choose Properties.
Paste the bookmarklet into the URL box and close.
Have you got any of the "ie7.js" shims loaded, too? I tried using "ie9.js" (a later version for IE8) and it screwed with Firebug Lite for me. I feel your pain; Firebug Lite is a damn sight better than the IE8's absolutely useless native tools.

JavaScript window.open function is displaying toolbar and menubar when instructed not to in IE7

I am currently trying to open another IE window using the code below, but the toolbar and menubar is still showing under IE7, it seems to work under IE8 though. Why is it doing this?
mywindow = window.open("dataviewer.aspx?id=" + id , "", "toolbar=no,location=no,directories=no,menubar=no");
I seem to recall having to add a website to my "trusted sites" list in IE7 to get the toolbars hidden. Of course that isn't going to help if you can't control that for your visitors, but I think it was something locked down as of IE7 -- even though MSDN doesn't state that. It might be an advanced setting, or maybe it was related to some 3rd party add-on or anti-virus I had. I just know I had a website that launched a small window that was meant to be a "floating toolbar" and it worked great in IE6, but once I upgraded to IE7 the width and height worked, but it had toolbars. I added that site to my trusted sites list, and it started working again.
If that is the case for you, I'd check the advanced security features and see what is different between normal and trusted sites, and maybe fine the one setting that controls this.
It works in IE7-mode in IE9. I don't have a machine with real IE7 installed.
The directories features is no longer supported. Just a guess, but that might be your problem.
One thing to try is to specify only "toolbar=no". Once you've specified to disable one of the features, the rest of them default to no. If you wanted no toolbars, but you did want an address bar, you'd have to explicitly say "location=yes" to get them back on. So, setting just one feature to no is good enough to turn the rest of them off as well.
Try this: http://jsfiddle.net/VD8sk/
mywindow = open("dataviewer.aspx?id=" + id , "", "toolbar=no");
Edit: Maybe also try "toolbar=no,menubar=no" without the other features specified.

Universal add to bookmarks script?

Does anyone know of a script that I can use to automatically add a site to favourites upon clicking of a link for multiple browsers? Atleast Firefox, IE, Chrome would be good.
If not, is there a way I can simulate ctrl+D through Javascript as I know that keystroke adds a site to bookmark in most browsers?
A universal script for adding to bookmarks doesn't exists, because not all browsers expose an API for creating bookmarks. Generally, only IE exposes a direct API for this. Both Opera and Firefox offer a possibility to add a site to bookmarks that will be opened in the sidebar and that is a huge difference. Safari and Chrome also don't expose any API for this task.
Some more info on this topic
I use a small script to attempt adding a bookmark using the most popular window methods, until all have failed. Then it just prompts the user to manually add their bookmark...
Like others have said (above) some browsers prohibit script-activated bookmarking, and because of security they want only users to add bookmarks.
It is not perfect, but it is simple and works well.
function addBookmark()
{
var success=false;
// try each until all fail...
try {
window.external.AddFavorite(window.location, document.title);
success=true;
} catch(e) {}
try {
window.sidebar.addPanel(document.title,location.href,'');
success=true;
} catch(e) {}
if(!success)
{
alert("AUTO BOOKMKARING not supported\r\nIn your current browser.\r\n\r\nPress CTRL+D, or CMD+D\r\nto manually bookmark this page.");
}
}
You can check out this jquery plugin if you are using that or just look at their source if you want to use your own. Though he mentions on his compatibility that Safari and Chrome do not expose this functionality in their API.
http://www.dummwiam.com/jFav
See digitalinspiration.
1st Google result for javascript bookmark.
In internet explorer it works with:
window.external.AddFavorite(document.location,document.title);
in firefox and in opera with:
Some link name
I haven't found a solution for safari / chrome yet.

Categories

Resources