Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
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
Old 05-14-2011, 11:22 PM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
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
AndrewGSW is offline   Reply With Quote
Old 05-14-2011, 11:50 PM   PM User | #3
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
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> ');
}
Simplyput is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:52 AM.


Advertisement
Log in to turn off these ads.