|
-
Sep 21st, 2005, 05:22 AM
#1
Thread Starter
Fanatic Member
javascript: changing the href
I am trying to write an after the fact fix for a bug in a blogging install. as it only happens once in a while and is rather minor I figred that javascript could cover the breach.
The javascript changes any instance of domain#1 for the more correct domain#2
Code:
<script language="JavaScript1.2">
<!--
//This hack covers up for BAD code in CMS
// Edit these two values (mostly the second one should be your domain
var fixdomain="myblog.com";
var mydomain="lordmatt.co.uk";
function dynamiclink(){
for (i=0; i<=(document.links.length-1); i++) {
document.links[i]=document.links[i].replace(fixdomain,mydomain);
}
}
window.onload=dynamiclink;
// -->
</script>
It doesn't work so I figure I done something wrong, but to be honest I suck at javascript. Sometimes it gives me errors in IE6 too.
-
Sep 21st, 2005, 07:39 AM
#2
Re: javascript: changing the href
Code:
document.links[i].href=document.links[i].href.replace(fixdomain,mydomain);
Works for me
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Sep 21st, 2005, 12:38 PM
#3
Thread Starter
Fanatic Member
Re: javascript: changing the href
Yep, and I can iterate through all the URLs useing alert (document.links[i].href); even though it's very annoying. But the changing urls to fix the odd few bad ones is just not happening. Not if FX or IE6
Code:
<script language="JavaScript1.2">
<!--
//This hack covers up for BAD code in CMS
// Edit these two values (mostly the second one should be your domain
function dynamiclink(){
var fixdomain="myblog.com";
var mydomain="lordmatt.co.uk";
for (i=0; i<=(document.links.length-1); i++) {
//document.links[i].href=document.links[i].href.replace("lordmatt","mad-den");
document.links[i].href=document.links[i].href.replace(fixdomain,mydomain);
// alert (document.links[i].href);
}
}
window.onload=dynamiclink;
// -->
</script>
this is where I am and this is what must change
Code:
<link rel='prev' href='http://myblog.com/item/gregarius-reuters-oddly-enough'/>
<link rel='next' href='http://myblog.com/item/most-lord-matt'/>
and
Code:
<a href='http://myblog.com/member/Lord Matt'>
<a href='http://myblog.com/category/advice'>
There are one or two others like this in the archives but as it's all dynamicly generated I can't just do a search and replace...
help...
-
Sep 21st, 2005, 01:33 PM
#4
Re: javascript: changing the href
Well, even if its dynamically generated it still has to come form somewhere. Why not search where the data is coming from and fix it there?
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Sep 21st, 2005, 01:51 PM
#5
Thread Starter
Fanatic Member
Re: javascript: changing the href
 Originally Posted by crptcblade
Well, even if its dynamically generated it still has to come form somewhere. Why not search where the data is coming from and fix it there?
Simply put I am fighting the mess that is a NeculusCMS fork called BLOG:CMS and although it looks good it has a few bugs that truely suck... and the code is a bugger to get into a mess of hacks and kludges and totally undocumented in PHP (Not my primary language) so I'd like to file a kludge of my own that will "fix" it for now.
I can stick the JavaScript into the template files.
http://lordmatt.co.uk - this is fine
but check out the perma link on this old rant: http://lordmatt.co.uk/item/gregarius...sked-questions
a quick view source show the javascript in place so I don't get what's happening.
-
Sep 21st, 2005, 05:33 PM
#6
Thread Starter
Fanatic Member
Re: javascript: changing the href
I've removed the JS for the time being. If any one knows of something less common that I have overlooked please speak up.
Thanks
-Matt
-
Sep 24th, 2005, 09:35 AM
#7
Thread Starter
Fanatic Member
Re: javascript: changing the href
I finally caved to the obviouse and found out how to fix the code (Get Necleus and stop buggering about with the usless slack hack that is Blog:CMS).
Thanks for the help and if any one ever figures out what the bug was I'd be interested to know.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|