Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Change HREF of a Link w JS.

Thread Tools

Change HREF of a Link w JS.

Posts: n/a

Ok, so I need to change the href of a link on our php driven auction
calendar. what I need to do is change the href in the "More Info"
button link from "auction_detail.php?ID=91582" to

I do not have access to the template or scripting that supplies the
html, and whoever designed it used the same name for similar div's,
i.e. EVERY more info button on the page has a div id of
"listMoreButton". So I can't reference the exact div and change it's
href. The reason I need to do this is that the html parser used by our
hosting company is retarded, does not work correctly. look at to see
what it does, and
to see what it's supposed to look like. Where I have that page already
in place and functioning correctly, I would rather just change the link
on the More Info button using JS than make them fix their html upload
utility (because they won't).

We have a sitewide global.js that executes onLoad. it does a variety
of things, and the function(s) i have written to do this simple change
do not work. Here is the code i have :

function kswap() {
var srch = "auction_detail.php?ID=91582";
var replc =
/*if (document.getElementById(listMoreButton).href == srch)
{document.getElementById(listMoreButton).href = replc}*/

for (var i=0; i<(document.links.length); i++)
if ([i].href == srch) {[i].href = replc;}

The commented out seciton was how i originally tried to get this to
work, but there are multiple div's with that id (listMoreButton).

I have spent hours searching and testing with no luck. I couldn't find
anyone in a situation similart to mine. Any help would be appreciated.
If there is any way to change the href of a link delivered through php
with a sitewide javascript that executes on page load, please help
point me in the right direction.

Thanks Already,

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change existing link's href - weird IE bug. automatyk Javascript 16 01-26-2008 08:08 PM
i want to change font_style (hyper link<a href...>text</a>) normal to italics,when load a page..? ASP .Net 3 03-09-2007 11:02 AM
Change <link> href attribute dynamically Simon Gorski ASP .Net Building Controls 2 03-06-2004 08:04 PM
Change <link> href attribute dynamically Simon Gorski ASP .Net 2 03-06-2004 08:04 PM
Problem: Setting MSIE iframe innerHTML change relative href/src to absolute href/src Soren Vejrum Javascript 4 07-05-2003 01:47 PM