inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Jun 19, 2012 15:57:09 GMT -8
|
|
inherit
24252
0
Aug 1, 2023 15:01:24 GMT -8
coolcoolcool
When the world says, "Give up," Hope whispers, "Try it one more time."
2,148
May 2004
coolcoolcool
|
Post by coolcoolcool on Jun 19, 2012 16:17:40 GMT -8
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Jun 19, 2012 16:22:59 GMT -8
its a proboards document lol. so it has body and html tags. thanks the new one works. How would you do this if the thing you were searching for was two of the same thing? but for each you wanted something different to happen. I tried having it match <a href="url"><img src="certain url" /></a> but it didnt work, are the extra / throwing it off?
|
|
inherit
24252
0
Aug 1, 2023 15:01:24 GMT -8
coolcoolcool
When the world says, "Give up," Hope whispers, "Try it one more time."
2,148
May 2004
coolcoolcool
|
Post by coolcoolcool on Jun 19, 2012 16:41:48 GMT -8
The exact same link? If you know ahead of time that there's only two, you could do this:
var a = document.getElementsByTagName("a"); var found = false; for(var i = 0; i < a.length; i++) { if(condition && !found) { a.innerHTML += "blah"; found = true; } else if(condition) a.innerHTML += "blah2"; }
However, that's only for this specific case. I normally would never treat a document in this way. If you have control over the links, the best way to do this is give them ID's like so:
<a id="FIRST" href="blah.html">link</a>
<script> document.getElementById("FIRST").innerHTML = "waaah"; </script>
And make sure each id is ONLY used ONCE. You're only allowed to use a specific id once per page. So give each link its own id and modify it with the above script.
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Jun 19, 2012 17:20:29 GMT -8
Well I don't have access to add an id. It's a part of the proboards stuff that's there
|
|
inherit
24252
0
Aug 1, 2023 15:01:24 GMT -8
coolcoolcool
When the world says, "Give up," Hope whispers, "Try it one more time."
2,148
May 2004
coolcoolcool
|
Post by coolcoolcool on Jun 20, 2012 3:25:39 GMT -8
Well I don't have access to add an id. It's a part of the proboards stuff that's there What exactly are you trying to do?
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Jun 20, 2012 5:04:33 GMT -8
Well I saw some request on code support. And I was trying to figure out how it could work. But it's add a link out beside the bookmark button in a thread.
|
|
inherit
24252
0
Aug 1, 2023 15:01:24 GMT -8
coolcoolcool
When the world says, "Give up," Hope whispers, "Try it one more time."
2,148
May 2004
coolcoolcool
|
Post by coolcoolcool on Jun 20, 2012 7:57:49 GMT -8
Notice the image element.
<img src="http://images.proboards.com/new/buttons/bookmark.png" alt="[Add Bookmark]" title="[Add Bookmark]" border="0"/>
You could loop through and check that img.alt.match and img.title.match. Then simply just do this: link = document.createElement("a"); link.href="link.html"; img.parentNode.parentNode.appendChild(link);
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Jun 20, 2012 8:07:32 GMT -8
Okay, I'm sorry, but can you please, explain that more? Forgive me. How would you loop through with img.alt.match? I'm a n00b with this kind of stuff. lol. And I really do want to learn.
|
|
inherit
24252
0
Aug 1, 2023 15:01:24 GMT -8
coolcoolcool
When the world says, "Give up," Hope whispers, "Try it one more time."
2,148
May 2004
coolcoolcool
|
Post by coolcoolcool on Jun 20, 2012 8:12:22 GMT -8
In the same way as before. for(var img = document.getElementsByTagName("img"), i = 0; i < img.length;i++) { if(img.alt.match(/\[add bookmark\]/i)) //do whatever }
The .parentNode returns the element that contains your source element. For example if you had the following <span><p id="test">blah</p></span>
document.getElementById("test").parentNode would return the span.
And no worries. We all have to start somewhere. I'm glad to help.
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Jun 20, 2012 8:17:19 GMT -8
for(var img = document.getElementsByTagName("img"), i = 0; i < img.length;i++) { if(img.alt.match(/\[add bookmark\]/i)) //do whatever } link = document.createElement("a"); link.href="link.html"; img.parentNode.parentNode.appendChild(link);
so it would go something like this? what goes where the red is?
|
|
inherit
24252
0
Aug 1, 2023 15:01:24 GMT -8
coolcoolcool
When the world says, "Give up," Hope whispers, "Try it one more time."
2,148
May 2004
coolcoolcool
|
Post by coolcoolcool on Jun 20, 2012 8:27:14 GMT -8
link.html is where you want the <a> tag to direct you.
You would have to put that stuff inside the if-statement, so that when it finds the image it adds the link to the td element. If you do it outside the for loop, you will get an error.
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Jun 20, 2012 8:32:12 GMT -8
okay so would just put support.proboards.com. I'm sorry to ask another question. but how would you go about mkaing the link an image? sorry to keep bothering
|
|
inherit
24252
0
Aug 1, 2023 15:01:24 GMT -8
coolcoolcool
When the world says, "Give up," Hope whispers, "Try it one more time."
2,148
May 2004
coolcoolcool
|
Post by coolcoolcool on Jun 20, 2012 8:39:50 GMT -8
link = document.createElement("a"); link.href="link.html"; image = document.createElement("image"); image.alt="[whatevs]"; image.title="[whatevs]"; image.src="image.png"; link.appendChild(image); img.parentNode.parentNode.appendChild(link);
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Jun 20, 2012 8:57:57 GMT -8
for(var img = document.getElementsByTagName("img"), i = 0; i < img.length;i++) { if(img.alt.match(/\[add bookmark\]/i)) //do whatever link = document.createElement("a"); link.href="#bottom"; image = document.createElement("image"); image.alt="[whatevs]"; image.title="[whatevs]"; image.src="image.png"; link.appendChild(image); img.parentNode.parentNode.appendChild(link); }
so put together like this?
|
|