View Single Post
Old 05-14-2011, 08:52 PM   PM User | #1
Simplyput
New to the CF scene

 
Join Date: May 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Simplyput is an unknown quantity at this point
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> ');
 }
Simplyput is offline   Reply With Quote