...

View Full Version : Javascript Link in Toolbar



netlatch
06-15-2008, 05:30 PM
I am trying to add a feature to a web site I am building that will allow users to drag a javascript link to their toolbar to use when browsing the Internet. The Javascript will open a page on my new site and allow them to add some information from the page they are on to it. I have managed to get the javascript to open the new page but it is always in the background. I have tried using the focus() attribute but to no avail. I am a PHP guy so Javascript is a little bit of a mystery to me.

Here is the script that I have managed to mangle together:

<a href="javascript:var l=window.location;var t=document.title;var url='http://krumler.com/drag-krum.php?link='+l+'&title='+t;var mywindow=window.open(url,'Add a Krum','width=650,height=700,top=0,left=0,location=1,resizable=1,scrollbars=1');mywindow.focus();"onclick="alert('To drag the link to your toolbar: click the link, hold the mouse button down, drag it to the browser toolbar and release the button or right click on link and select bookmark this link to add it to your toolbar.');return false;">Add-Krum</a> to your tool bar</p>

Any help would be appreciated. I figure that I must be doing something stupid here but I am not smart enough to see it.

Philip M
06-15-2008, 06:51 PM
Try this:

<a href="javascript:var l=window.location;var t=document.title;var url='http://krumler.com/drag-krum.php?link='+l+'&title='+t;var mywindow=window.open(url,'Add a Krum','width=650,height=700,top=0,left=0,location=1,resizable=1,scrollbars=1')" onclick = "mywindow.focus(); alert('To drag the link to your toolbar: click the link, hold the mouse button down, drag it to the browser toolbar and release the button or right click on link and select bookmark this link to add it to your toolbar.');return false;">Add-Krum</a> to your tool bar</p>

netlatch
06-15-2008, 07:08 PM
Philip, Thanks for your reply. I tried that and it is still not working though. It does work in Safari but not in FireFox

netlatch
06-15-2008, 07:12 PM
BTW I am trying to open a new browser window when some one clicks on the tool bar link and then I am passing some information from the "old" window to the new window. It is the new window I want to have focus.

Philip M
06-16-2008, 08:08 AM
You make it hard to debug when you run all the lines of code together. And naming a variable l is fraught with danger - too easily misread as 1. onc lick does not help either.

Part of the problem is your window name 'Add a Krum' which is invalid (spaces).

This works in IE:-


<p><a href="#" onclick = "showPop()"> Add Krum</a> to your toolbar</p>

<script type = "text/javascript">

function showPop() {
var loc=window.location;
var t=document.title;
var url='http://krumler.com/drag-krum.php?link='+loc+'&title='+t;
var mywindow = window.open(url,'AddKrum','width=650,height=700,top=0,left=0,resizable=1,scrollbars=1');
alert('To drag the link to your toolbar: click the link, hold the mouse button down, drag it to the browser toolbar and release the button or right click on link and select bookmark this link to add it to your toolbar.');
mywindow.focus();
return false;
}
</script>


All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

netlatch
07-23-2008, 02:42 PM
Philip, I am sorry but I did not realize you had responded to my post (weeks ago). I am not sure but I don't think you understand what I am trying to do. To see what I have already in place go to http://krumler.com/quick-start.php

You can drag the link I have on that page onto your browser toolbar and try it. When you click that toolbar link it should open a new window with the page title and url from the window you were previously viewing. This new window should also have focus. What I have there now works with FF and Safari but in FF the window that the toolbar link opens is in the background and I want it to have focus. I also can't seem to be able to drag links onto the toolbar in IE.

Thanks

netlatch
07-23-2008, 09:11 PM
my link now works good in IE7 and safari but not fire fox. still can't figure why. fire fox is usually the best at following the rules

netlatch
07-23-2008, 10:13 PM
Figured it out! It is an issue with FireFox. There is a bug. https://bugzilla.mozilla.org/show_bug.cgi?id=232605

this is the work around for any one who has this problem and has found this post looking for answers

javascript:w=window.open();setTimeout("w.focus()",
0);void(w.location="http://www.mozilla.org")



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum