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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    add an open window attribute to an existing javascript function

    I have this social bookmarking javascript that works great. However, when a user clicks on one of the icons it takes them away from my page to the social book mark. I would like it to open a new window to the open book mark. I have tried multiple times to modify the code but fail at every turn. Can someone please help me?

    The untoched code

    Code:
     
    var image_dir="http://www.yoursige.com/images";
    
    function add_tool(icon, name, url) {
      document.write('<span class="socialAddButton" id="socialAddButton-' + icon + '"><a href="' + url + 'title="Add to ' + name +'"><img src="' + image_dir + '/' + icon + '.png" alt="' + name + ' icon" /></a></span> ');
    }
    
    function add_all() {
      var title = encodeURIComponent(document.title);
      var url = encodeURIComponent(document.URL);
    
      add_tool('delicious', 'del.icio.us', 'http://del.icio.us/post?url=' + url + '&amp;title=' + title);
      add_tool('digg', 'digg', 'http://digg.com/submit?phase=2&amp;url=' + url + '&amp;title=' + title);
      add_tool('spurl', 'Spurl.net', 'http://www.spurl.net/spurl.php?url=' + url + '&amp;title=' + title);
      add_tool('simpy', 'Simpy', 'http://www.simpy.com/simpy/LinkAdd.do?href=' + url + '&amp;title=' + title);
      add_tool('newsvine', 'Newsvine', 'http://www.newsvine.com/_tools/seed&amp;save?u=' + url + '&amp;h=' + title);
      add_tool('blinklist', 'BlinkList', 'http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=' + url + '&amp;Title=' + title);
      add_tool('furl', 'Furl', 'http://www.furl.net/storeIt.jsp?u=' + url + '&amp;t=' + title);
      add_tool('reddit', 'reddit', 'http://reddit.com/submit?url=' + url + '&amp;title=' + title);
      add_tool('fark', 'FARK', 'http://cgi.fark.com/cgi/fark/edit.pl?new_url=' + url + '&amp;new_comment=' + title + '&amp;linktype=');
      add_tool('blogmarks', 'BlogMarks', 'http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=' + url + '&amp;title=' + title);
      add_tool('yahoo', 'Yahoo! My Web', 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u=' + url + '&amp;t=' + title);
      add_tool('smarking', 'smarking', 'http://smarking.com/editbookmark/?url=' + url + '&amp;title=' + title);
      add_tool('magnolia', 'Ma.gnolia', 'http://ma.gnolia.com/bookmarklet/add?url=' + url + '&amp;title=' + title);
      add_tool('segnalo', 'Segnalo', 'http://segnalo.com/post.html.php?url=' + url + '&amp;title=' + title);
    }
    
    add_all();
    My last failed attempt was to add a target_blank in frustration.
    Code:
    function add_tool(icon, name, url) {
      document.write('<span class="socialAddButton" id="socialAddButton-' + icon + '"><a href="' + url + '" title="Add to ' + name +'" target="_blank"><img src="' + image_dir + '/' + icon + '.png" alt="' + name + ' icon" /></a></span> ');
     }

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    You may have done so already, but I would try it in different browsers to see if it is a problem with a specific browser (IE anyone ).

    Also check browser settings to see if there is one preventing it from opening a new window from a link.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #3
    New to the CF scene
    Join Date
    May 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Solved

    Okay I solved this problem by modifying the code displayed below and having the script point to the correct website. The big dummy that i am did not see this after hours of working through code that should of worked Now I have a new issue so I will work on that before I ask any more questions for the day. Thanks everyone who took a look at it.

    Code:
    function add_tool(icon, name, url) {
      document.write('<span class="socialAddButton" id="socialAddButton-' + icon + '"><a href="' + url + '" target="_blank" title="Add to ' + name +'"><img src="' + image_dir + '/' + icon + '.png" alt="' + name + ' icon" /></a></span> ');
    }


  •  

    Posting Permissions

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