16.9k times

Trying to get phpBB to create a link on their new forum link type of forum. Unfortunately you can't pass variables from PHP to the link. To get around that, got this going:

Created a forum thats a link with http://changeme as the link

at the overall footer I threw in

<script type="text/javascript">
New = "<a href=\"{S_PLAYER_ID}\" class=\"forumtitle\">Roster</a>"
a = document.getElementsByTagName("dt")
for (i=0; i<a.length; i++)
if((a[i].innerHTML.match("<a href=\"http://changeme\" class=\"forumtitle\">Roster</a>"))){a[i].innerHTML=a[i].innerHTML.replace("<a href=\"http://changeme\" class=\"forumtitle\">Roster</a>",New);

Works in Safari/FF but of course IE doesn't. What is a good workaround or recoding to do here?


add a comment

4 Answers

  • Votes
  • Oldest
  • Latest

Hello quick response as I just found out what was wrong with my code (had a similar problem with IE) instead of using the replace with text like you did use a regular expression

before I had this

.replace('<img src="images/correct.png" alt="valid" width="20px">', "");

but it wouldnt work on IE but then I changed it to

.replace(/^<.*">/g, "");

and it worked! just be sure to not use "" or '' around the regular expression!

Hope it helps 🙂

Ada J wong

add a comment

I don't really know whats the problem. I barely know JS but:
Don't care about the IE, nobody smart uses it nowadays 🙂
Some things just don't work on there.

add a comment

Well I have been looking around at posts about replace not working in IE, so instead decided to find a different script:

It appears to be working! A quick touch up will fix it all, thanks Ozzu!

add a comment