JavsScript Not working in WP :(

5 replies
Hey guys!

Need your help on a little thingie.

I have this little script which dynamically changes the Ad_Track in the aweber form on that page.

<!-- Aweber Adtracking Script Start -->
<script type="text/javascript">
window.onload=function(){var aw_ref='';var query=window.parent.location.search.substring(1);v ar vars=query.split("&");for(var i=0;i<vars.length;i++){var pair=vars[i].split("=");if(pair[0]=='ref'){aw_ref=pair[1];break } }for(i=0;i<document.forms.length;i++){for(e =0;e<document.forms[i].elements.length;e++){if(document.forms[i].elements[e].name=='meta_adtracking'){document.forms[i].elements[e].value=aw_ref;break } } } }
</script>
<!-- Aweber Adtracking Script Finish -->


Here's how it works:

I send peeps to my site with a /?ref=blabla

and then the script assign "blabla" as the Ad_Track of the prospect.

For some reason, in wordpress, I get an error trying to put this code on my pages.

Any idea why?

Thanks in advance!!!

PS. If someone have another solution it's also cool
#javsscript #working
  • Profile picture of the author onlinecasinodeck
    Originally Posted by adamgoldman47 View Post

    Hey guys!

    Need your help on a little thingie.

    I have this little script which dynamically changes the Ad_Track in the aweber form on that page.

    <!-- Aweber Adtracking Script Start -->
    <script type="text/javascript">
    window.onload=function(){var aw_ref='';var query=window.parent.location.search.substring(1);v ar vars=query.split("&");for(var i=0;i<vars.length;i++){var pair=vars[i].split("=");if(pair[0]=='ref'){aw_ref=pair[1];break } }for(i=0;i<document.forms.length;i++){for(e =0;e<document.forms[i].elements.length;e++){if(document.forms[i].elements[e].name=='meta_adtracking'){document.forms[i].elements[e].value=aw_ref;break } } } }
    </script>
    <!-- Aweber Adtracking Script Finish -->


    Here's how it works:

    I send peeps to my site with a /?ref=blabla

    and then the script assign "blabla" as the Ad_Track of the prospect.

    For some reason, in wordpress, I get an error trying to put this code on my pages.

    Any idea why?

    Thanks in advance!!!

    PS. If someone have another solution it's also cool
    try to find the footer.php in your themes folder and then edit it, include the code inside the footer.php, something like this bellow

    <?
    footer code
    ?>
    <!-- Aweber Adtracking Script Start -->
    <script type="text/javascript">
    window.onload=function(){var aw_ref='';var query=window.parent.location.search.substring(1);v ar vars=query.split("&");for(var i=0;i<vars.length;i++){var pair=vars[i].split("=");if(pair[0]=='ref'){aw_ref=pair[1];break } }for(i=0;i<document.forms.length;i++){for(e =0;e<document.forms[i].elements.length;e++){if(document.forms[i].elements[e].name=='meta_adtracking'){document.forms[i].elements[e].value=aw_ref;break } } } }
    </script>
    <!-- Aweber Adtracking Script Finish -->

    also you can include it on the header.php, between <head> and </head>

    something like this
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>

    <!-- Aweber Adtracking Script Start -->
    <script type="text/javascript">
    window.onload=function(){var aw_ref='';var query=window.parent.location.search.substring(1);v ar vars=query.split("&");for(var i=0;i<vars.length;i++){var pair=vars[i].split("=");if(pair[0]=='ref'){aw_ref=pair[1];break } }for(i=0;i<document.forms.length;i++){for(e =0;e<document.forms[i].elements.length;e++){if(document.forms[i].elements[e].name=='meta_adtracking'){document.forms[i].elements[e].value=aw_ref;break } } } }
    </script>
    <!-- Aweber Adtracking Script Finish -->

    </head>
    {{ DiscussionBoard.errors[4582695].message }}
    • Profile picture of the author krifa
      Did that work for you? I have a similar problem and the solution is not working for me.
      {{ DiscussionBoard.errors[4584823].message }}
  • Profile picture of the author adamgoldman47
    I already tried that.

    Krifa, if you find a solution post it here or PM me ok?

    I'll do the same!

    I've sent an email to some friends of mine maybe they'll get back at me in the weekend.

    Say krifa,

    what exactly is your problem?

    Also JS not working?
    {{ DiscussionBoard.errors[4589237].message }}
  • Profile picture of the author adamgoldman47
    Got my solution guys!

    Thanks anyhow

    I just placed the JavaScript in another file and called for it from the page.

    Krifa,

    have you tried that?
    {{ DiscussionBoard.errors[4589505].message }}
    • Profile picture of the author feelingunlucky
      Banned
      [DELETED]
      {{ DiscussionBoard.errors[4612188].message }}
      • Profile picture of the author joekyut
        Originally Posted by feelingunlucky View Post

        This also helped me Thanks!
        I will add my thanks too
        {{ DiscussionBoard.errors[4612406].message }}

Trending Topics