1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help a dummy with Javascript

Discussion in 'HTML & JavaScript' started by Setox, Jul 3, 2017.

  1. Setox

    Setox Power Member

    Joined:
    Apr 30, 2015
    Messages:
    581
    Likes Received:
    243
    Occupation:
    CPA Hunting
    Location:
    MALTA MAYBE ..
    Hello guys , I need a little help with javascript .

    So , I have a landing page with some ebooks + a download link + a content locker on it , that locker is launched on click , whenever someone click "download" , and i don't want to create a separated locker for each ebook , coz it's time consuming and bad for collecting data , as i have the same template .
    Thankfully I found this on Adworkmedia , it allow me to pass the redirect url in a Variable called "&go="

    "The redirect URL may be overwritten from the JavaScript integration code so it can be populated dynamically from the page by attaching the "&go=http://YOUR_REDIRECT_URL.com" variable."

    Adworkmedia locker code look like this :

    Code:
    <script type="text/javascript">awm = false;</script>
    <script class="datalink" src="http://www.loktrk.com/gLoader.php?GID=XXXXX&go=&sid=" type="text/javascript"></script>
    <script type="text/javascript">if (!awm) { window.location = 'http://loktrk.com/help/removeAB.php'; }</script>
    <noscript>Please enable JavaScript to access this page.  <meta http-equiv="refresh" content="0;url=http://loktrk.com/help/enableJS.php" /></noscript>
    Now for the redirect url I just want to integrate differents variable in urls so the thank you page will fetch that variable value & show user their desired content , I can handle this . so let's get back to the problem .

    To pass that redirect link to the adworkmedia code , i tried the following solution : it seemed that it works the first time , but when I test it with the locker nothing happen & the locker couldn't find a redirect link (because i set up the locker for a test by letting it redirect without showing offers) .
    I don't know if the problem is because i'm calling two functions onclick , i know it's possible with JS , but i'm afraid i'm doing something wrong , or my below function can't work with script tag .. so if someone could suggest something more proper .

    Here is what i'm using :

    Code:
    function someFunc() {
        $('.datalink').attr('src', function() {return this.src + '&go=https://blackhatworld.com';});
    }
    so i added a class (datalink) to the script tag that contain my locker link , then that function will fetch for the element that contains the class & change the src attribute attached to it by adding the variable i want . I have to duplicate that function and change the redirect url to match the ebooks i have, I found that script in the web & it's supposed to work with href links but i just changed it to src, & it worked fine.

    here is the onclick att value i added to each download button :

    the first function "gload" is the one to call the locker, it remains the same , for the second one , it's to append the redirect url , i'll have to change it .

    Code:
    onclick="gLoad_XXXX();SomeFunc2();"
    So i hope someone experienced with javascript could help me achieve my goal , appending that variable to that link without refreshing the page & locker still works fine .

    Thank you .
     
  2. Setox

    Setox Power Member

    Joined:
    Apr 30, 2015
    Messages:
    581
    Likes Received:
    243
    Occupation:
    CPA Hunting
    Location:
    MALTA MAYBE ..
    NO JS geek here ??