Asked
Updated
Viewed
17.7k 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 I created a forum that's a link with https://changeme as the link. In the the overall_footer I placed some Javascript:

New = "<a href=\"http://domain.com/players.php?pid={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);
}

It works in Safari/FF but of course, IE doesn't. What is a good workaround or a different way to program this where it will also work correctly in IE?

  • 0
    I don't really know what the problem is. I barely know JS but I also don't care about the IE, nobody smart uses it nowadays 🙂 Some things just don't work on there. — Zielak69
  • 0
    What makes you say that? See this: https://en.wikipedia.org/wiki/Usage_share_of_web_browsers — casablanca
  • 0
    Besides the answer provided here, I was also looking around at other posts about replace not working in IE, so instead decided to find a different script that appears to be working! A quick touch-up will fix it all, thanks Ozzu! — dyfrin
add a comment
1

1 Answer

  • Votes
  • Oldest
  • Latest
Answered
Updated

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 wouldn't 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!

add a comment
1