Pass variable to javascript use javascript

Client wants add following tracking code on website:

<script type="text/javascript" src="http://www.demo.com/show.php?mpt=[CACHEBUSTER]&mpvc=">
</script>
<noscript>
  <a href="http://www.demo.com/show.php?mpt=[CACHEBUSTER]">
    <img src="http://www.demo.com/show.php?mpt=[CACHEBUSTER]" alt="Click Here" border="0">
</a>
</noscript>

To ensure accurate tracking, they want [CACHEBUSTER] can be replaced by a Time Stamp when page reload.

This is the way we use:

<script type="text/javascript">
var currentTime = new Date(); 
var time_stamp = currentTime.getTime(); 

document.write('<scr' + 'ipt type="text/javascript" src="http://www.demo.com/show.php?var=' + time_stamp + '"></scr' + 'ipt>');
document.write("<noscr' + 'ipt>");
document.write('<a href="http://www.demo.com/show.php?mpt=' + time_stamp + '">');
document.write('<img src="http://www.demo.com/show.php?mpt=' + time_stamp + '" alt="Click Here" border="0"></a>');
document.write('</noscr' + 'ipt>');
</script>
affiliate_link
Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

No Responses to “Pass variable to javascript use javascript”

Leave a Reply:

Name (required):
Mail (will not be published) (required):
Website:
Comment (required):
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>