Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Javascript Link in Toolbar

    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();"onc lick="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.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    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>

  • Users who have thanked Philip M for this post:

    netlatch (06-15-2008)

  • #3
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Philip, Thanks for your reply. I tried that and it is still not working though. It does work in Safari but not in FireFox

  • #4
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    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:-

    Code:
    <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.
    Last edited by Philip M; 06-16-2008 at 08:29 AM.

  • #6
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  • #7
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    update

    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

  • #8
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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")


  •  

    Posting Permissions

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