Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
55
rated 0 times [  56] [ 1]  / answers: 1 / hits: 81582  / 14 Years ago, sat, may 15, 2010, 12:00:00

I have this so far:


chrome.tabs.getSelected(null, function(tab) 
{
var title = tab.title;
var btn = '<a href="' + tab.url + '" onclick="save('' + title + '');"> ' + title + '</a>';

if(tab.url.match('/http://www.example.com/version.php/i'))
{
document.getElementById('link').innerHTML = '<p>' + btn + '</p>';
}
});

Basically it should match the domain within this:


http://www.example.com/version.php?*

Anything that matches that even when it includes something like version.php?ver=1, etc


When I used the code above of mine, it doesn't display anything, but when I remove the if statement, it's fine but it shows on other pages which it shouldn't only on the matched URL.


EDIT:


if(tab.url.match(/http://www.example.com/version.php/i)) 
{
document.getElementById('link').innerHTML = '<p>' + btn + '</p>';
}

Doesn't even work somehow...


More From » regex

 Answers
21

Try this:


if(tab.url.match(/http://www.example.com/version.php/i)) 
{
//...
}

[#96783] Tuesday, May 11, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rossthomasn

Total Points: 122
Total Questions: 78
Total Answers: 105

Location: South Georgia
Member since Sun, Aug 8, 2021
3 Years ago
rossthomasn questions
Wed, Mar 16, 22, 00:00, 2 Years ago
Wed, May 5, 21, 00:00, 3 Years ago
Thu, Nov 26, 20, 00:00, 4 Years ago
Sun, May 31, 20, 00:00, 4 Years ago
;