Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Central

Getting links to open in safari without regular HTML

Author Message
zweben



Joined: 04 Apr 2005
Posts: 10
Location: New Jersey, USA

Posted: Tue Oct 04, 2005 - 9:08 pm    Post subject: Getting links to open in safari without regular HTML Reply with quote

I am making a shoutbox widget that displays a PHP feed. The problem i'm having is that when the feed has a link in it, it's in regular HTML format. I want these links to open in Safari, but I can't change each individually because I can't change the contents of the feed.

I've heard that there is a way to get regular HTML formatted links to work with javascript, but i'm not sue what it is I need. Any help is appreciated.
View user's profile Send private message Send e-mail Widgets
purvisa



Joined: 21 Jul 2005
Posts: 182
Location: Kirkland, WA

Posted: Wed Oct 05, 2005 - 2:08 am    Post subject: Reply with quote

You can use Javascript to extract a link element from HTML, but the method can be a little kludgy.

Every HTML document contains an array of link elements (links[], I believe, but it has been a while since I checked), as Javascript sees it, and you can cycle through the array with a for{} loop, taking just the part between the quotes in the anchor tag out of each. You can then operate on each URL in turn.

Hope that helps.
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger Widgets
funkdaddy



Joined: 25 Apr 2005
Posts: 35

Posted: Mon Oct 10, 2005 - 8:14 am    Post subject: Reply with quote

Can't you use a JS search/replace to replace "<a href="theURL"> to "<a href="#" onClick="widget.openURL('theURL');">" inside the string?
View user's profile Send private message Send e-mail Widgets
galendw



Joined: 30 May 2005
Posts: 71
Location: Here.

Posted: Mon Oct 10, 2005 - 9:11 am    Post subject: Reply with quote

funkdaddy wrote:
Can't you use a JS search/replace to replace "<a href="theURL"> to "<a href="#" onClick="widget.openURL('theURL');">" inside the string?


You could try something like this (UNTESTED):

Code:
var q = '<a href="http://www.dashboardwidgets.com">';
q = q.replace(/a href=/, 'a href="#" onClick="widget.openURL\(\'');
q = q.replace(/">/, '\')\;\)">');


Again, I haven't tested that. I'm sure if it'll work, but what you need is something along those lines.
_________________
View user's profile Send private message Send e-mail Visit poster's website Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group