Acces onClick link
2 posters
Page 1 of 1
Acces onClick link
How can I access with javascript to link. For example there is category, and inside it there are forums. When someone click on forum I want to trigger javascript. How?
Light Elf- Forumember
- Posts : 144
Reputation : 11
Language : English
Re: Acces onClick link
Set an event listener.
element.setEventListener() or element.attachEvent.
Though you can use jQuery's events API, and just do $(selector).click(function(e) { });
Which does the same stuff, but sorts out all the browser support for you.
element.setEventListener() or element.attachEvent.
Though you can use jQuery's events API, and just do $(selector).click(function(e) { });
Which does the same stuff, but sorts out all the browser support for you.
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Re: Acces onClick link
Can you give me one example how to use this? I am unknown with this part of javascript, and mostly with jQuery.
Light Elf- Forumember
- Posts : 144
Reputation : 11
Language : English
Re: Acces onClick link
I actually wrote a script on FMQuery for this exact purpose a while ago, here it is:
For example this bit: f43: 'http://avacweb.com/'
Means clicking on the link to forum 43 (check their unique ID in their URL) will redirect to avacweb.com
- Code:
var copyright_notice = 'Redirection Forums script for Forumotion Boards. Copyright © by LGforum. All Rights Reserved. Use and modification of this script is not allowed without this entire copyright notice in the original, copied, or modified script. No distribution without consent.';
var redirectForums = {
f43: 'http://avacweb.com/',
f46: 'http://malware-site.www/'
};
(function(){
var fid = window.location.pathname.replace(/.*\/(f\d+)-.*/,'$1');
if(fid in redirectForums) window.location = redirectForums[fid];
})();
$(function(){
var rows = $('.forums dl.icon').get();
for(var i=0,l=rows.length;i<l;i++) {
var flink = rows[i].getElementsByTagName('h3')[0] || rows[i].getElementsByTagName('h2')[0];
if(!flink) continue;
flink = flink.firstChild;
var fid = flink.href.replace(/.*\/(f\d+)-.*/,'$1');
if(fid in redirectForums) {
var new_link = redirectForums[fid];
flink.href = new_link;
flink.setAttribute('target','_blank');
while( rows[i].lastChild.className != 'dterm') { rows[i].removeChild(rows[i].lastChild)}
}
}
});
For example this bit: f43: 'http://avacweb.com/'
Means clicking on the link to forum 43 (check their unique ID in their URL) will redirect to avacweb.com
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Re: Acces onClick link
My idea was to triger a prompt box when someone click on forum in category. And when he enter good password he will be redirected into, else he will stay where he is.
Light Elf- Forumember
- Posts : 144
Reputation : 11
Language : English
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum