Best Collegue,
i've created a bookmarklet for IE and bumped against the following problem. When the user drag my bookmarklet in bookmarklet toolbar and click on it IE shows a dialog if the user want to allow the popup. But Pinterest made it possible to avoid this can someone tell me how pinterest find a solution to that problem?
my extern js file looks like:
function Bookmarker(){
initialize();
}
function initialize(){
var url = document.location.href;
loadBookMarkLet(url);
}
function loadBookMarkLet(url) {
newwindow = window.open('http://bookmarker.symbaloo.com/?url='+encodeURIComponent(url),'Bookmarklet','toolbar=no,width=550,height=330,left=500,top=200, status=no,scrollbars=no,resize=no');
setTimeout(function() {
newwindow.focus();
}, 0);
}
new Bookmarker();
my index.html files looks like:
<a href="javascript:(function(){script=document.createElement('SCRIPT');script.type='text/javascript';script.src='http://navidmirzaie.com/bookmarklet/default.js?x='+(Math.random());document.getElementsByTagName('head')[0].appendChild(script);})();" icon="bookmarker_icon.ico">Symbaloo Bookmarklet</a>
I would be very gratefull.
Tnx in advanced.
There are two ways this issue is generally handled.
1.) Instead of using a window, create a div in the page. The div can optionally contain an iframe.
2.) A window can be opened without warning in most browsers if the action follows DIRECTLY from a user initiated action.
If the bookmarklet first appends a script file, and then the code in the script file opens the window, this is not direct.
If however the bookmarklet code itself opens the window, this is direct. This will work.
A hybrid solution could be to have the bookmarklet open the window, and then append a script file. The code in the appended script file could then use the already opened window.
If your sample code is close to what you really want to use, I would just use it directly in a bookmarklet and skip the step of appending an external file.