PDA

View Full Version : [HELP]someone knowledgable in jQuery


Dr.CustUmz
03-09-2016, 05:40 PM
so we have a html link
<a href="http://google.com">Google</a>

and we target the google.com part like this
return this.each(function(){
var link = $(this);
var url = settings.service
.replace("__URL__" , link.attr("href"))
.replace("__DOMAIN__", link.attr("href")
.replace("http://","").replace("https://", ""));.......more code

and this works, for my normal href's

but i want to target a link like this
<a href="out.php?link=http://google.com">Google</a>
so the end __URL__ is only "google.com"

i have tried many ways, and looking at this code the obvious replace has been done
replace("out.php?link=http://","").replace("out.php?link=https://", "")

im stuck, i set a demo up HERE (http://drcustumz.me/test.html)

Dave
03-09-2016, 05:44 PM
Might be easier to make use of split like this:
"out.php=?link=http://google.com".split('//')[1]

will output "google.com".

Dr.CustUmz
03-09-2016, 05:50 PM
did you take a look at the demo dave? i implemented the split but im still not getting the desired results

--------------- Added 1457553299 at 1457553299 ---------------

this is the full code
jQuery.fn.favicons = function(config){
var settings = jQuery.extend({
"classname": "favicon",
"service": "http://api.byi.pw/favicon?url=__URL__"
}, config);

return this.each(function(){
var link = $(this);
var url = settings.service
.replace("__URL__" , link.attr("href"))
.replace("__DOMAIN__", link.attr("href")
.replace("http://","").replace("https://", ""));
link.css("background-image", "url(" + url + ")")
.addClass(settings.classname);
});
};