How to modify blankwin.js script?
Posted: 16 May 2008 09:51 AM   [ Ignore ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6563
Joined  04-15-2006

Hi there,

Just wondering if any Javascript gurus out there could possibly help me to figure something out?

I am using the great little blankwin.js script on a site and it works fine.

I have one slight need though. I would like to be able to not have it affect certain external links so I was thinking that perhaps I could place a certain class name on those links say something like css=“my-class disregard-blankwin” and then I can check for the disregard-blankwin part and if it exists on any links don’t apply the blankwin.js script

I did have a go by placing this :

/* SOF - My Code */
for(i=0;i<a.length;i++){
// Check for the right classname
if(a[i].className != "disregard-blankwin"){
/* EOF - My Code */

into the blankwin.js script just after the :

var a = document.getElementsByTagName("a");

part and hoped that any links with that class name would get overlooked but it still just operated in the same way that it did originally. Just to mention that I did put in the two closing } brackets after the rest of the blankwin.js code so the javascript was all valid but it still seems to just get all the a links and apply the script regardless of the if className part that I have put in!

If anyone has any idea of what I am bufooning on about and can lend a hand then I would be most appreciative. My Javascript really isn’t that good and I find it quite difficult to get my head around at the moment what with everything else going on inside my noggin so thanks for any help on this. I did try though honest as can be seen from the code I tried to inject into the existing javascript wink grin wink

Thanks in advance for any help on this one.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 16 May 2008 10:55 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  254
Joined  03-23-2006

If I understood you correctly you inserted a second loop into the program? If so you had the right idea at the wrong place try this:

...
for (var
i=0;i<a.length;i++){
    
if(a[i].className!="disregardBlankwin"){
        
if(check(a[i])) set(a[i]);
    
};
};
...

You see all the other parts of the program don’t get called except for the if(check…) loop, so you have to wrap your additional disregard filter around that, also I’m not too sure about using hyphens in class names (i.e disregard-Blankwin).

EDIT: I hope it is clear that this is supposed to go on line 14 in the original script.

Profile
 
 
Posted: 16 May 2008 12:36 PM   [ Ignore ]   [ # 2 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6563
Joined  04-15-2006

Hiya,

Thanks for the reply. I did try placing your code into the original code. Not too sure that it is line 14 though? More like line 22 maybe?

Did place it so that it looks the same as yours though but it still doesn’t work unfortunately. I have attached my script with the changes to this post - maybe you could possibly take a look and let me know where I have gone wrong?

Thanks again for the help on this.

Best wishes,

Mark

File Attachments
blankwin.js.zip  (File Size: 1KB - Downloads: 10)
 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 16 May 2008 12:52 PM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  254
Joined  03-23-2006

I’ll have a look a bit later… but if you have jquery already loaded this would do the same thing:

$('a[href^=http]:not(.disregardBlankwin)').not('[href*=yourdomain.com]').addClass('external');

just as an afterthought, you did add the class disregardBlankwin to some links?

Profile
 
 
Posted: 16 May 2008 01:14 PM   [ Ignore ]   [ # 4 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6563
Joined  04-15-2006

Hiya,

Thanks for that code will try that out instead now. Yep I did add in the new class name to the links as well though wink

Thanks again. If you wouldn’t mind looking later on as I would love to understand all of this and learning from getting the blankwin.js script working (well you would be doing that really - getting it working I mean wink ) would be a good way to start for me.

Thanks again.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64978 Total Logged-in Users: 32
Total Topics: 82017 Total Anonymous Users: 14
Total Replies: 440827 Total Guests: 165
Total Posts: 522844    
Members ( View Memberlist )