DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   Insert a script with javascript? (http://www.daniweb.com/forums/thread116237.html)

Inny Mar 28th, 2008 11:15 pm
Insert a script with javascript?
 
1 Attachment(s)
Im trying to insert a script

<div class="js-kit-comments" permalink=""></div>
<script src="http://js-kit.com/comments.js"></script>

into my boards profiles page

<tr>
            <td class="row3" valign='top'><b>Country</b></td>
            <td align='left' class='row1'>Australia</td>
          </tr>
  </table>

board http://inny.ipbfree.com/index.php?

to a particular spot beneath a td (profile field) called 'country'

I cant seem to get it to happen. can anyone help?

code I tried


<script>
//Godkillah, phantom-designs.net
tehsrc='http://js-kit.com/comments.js'
if(location.href.match(/showuser=[0-9]+/i)){script=document.createElement("script");script.src=tehsrc;a=document.getElementsByTagName("td");for(i=0;i<a.length;i++){if(a[i].document.getElementById('td').innerHTML='<div class="js-kit-comments" permalink=""></div>';  && a[i].getElementsByTagName("b")[0].innerHTML=='Country' && a[i].className=='row3'){a[i].appendChild(script);break;}}}
</script>

hielo Mar 29th, 2008 1:00 am
Re: Insert a script with javascript?
 
In your inner if you have this:
a[i].document.getElementById('td').innerHTML='<div class="js-kit-comments" permalink=""></div>'; && ...

which is doing assignment(single equal sign), not testing(two equal signs). Furthermore, that semicolon should be giving you errors. I believe it should be:
if( a[i].document.getElementById('td').innerHTML=='<div class="js-kit-comments" permalink=""></div>' ...

Inny Mar 29th, 2008 1:14 am
Re: Insert a script with javascript?
 
Tried This But nothing appeared at all

<script>
//Godkillah, phantom-designs.net
tehsrc='http://js-kit.com/comments.js'
if(location.href.match(/showuser=[0-9]+/i)){script=document.createElement("script");script.src=tehsrc;a=document.getElementsByTagName("td");for(i=0;i<a.length;i++){if( a[i].document.getElementById('td').innerHTML=='<div class="js-kit-comments" permalink=""></div>'  && a[i].getElementsByTagName("b")[0].innerHTML=='Country' && a[i].className=='row3'){a[i].appendChild(script);break;}}}
</script>


All times are GMT -4. The time now is 2:03 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC