SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I make javascript variables alter code like Google AdWords.

    I wanna make a banner exchange script with php where ppl place a piece of code (called the Prowler Exchange Code) on their site which displays all the reciprocal links.

    Example is here. Please read it. This is what I wanna code.

    The trouble is, I now have to use javascript in my script i need to code as webmasters linking to php for their Prowler Exchange Code using iframes is very silly.

    So how can I do what Google AdWords and Adgridwork and Txtswap do. How the code has some variables in it and then it retrieves the data from a database.

    How can I use javascript to give each sites it's identification.

    I'll be grateful for your answer.

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script type="text/javascript">
    publisherid = 'something';
    variable1 = 'something';
    variable2 = 'something';
    //your code can access these variables!
    </script>
    <script type="text/javascript" src="http://example.com/your-ad-serving-script.js"></script>
    your-ad-serving-script.js sits on your server. It is just a bit of JavaScript that draws a borderless iframe of the appropriate size with a src attribute pointing to the script that actually serves the ads from your database. The JavaScript puts the publisherid in the iframe's src so your script has access to it like any other GET variable sent as part of a URL.

    This is just how AdSense does it. Their JavaScript has access to the other JavaScript variables declared before it's included, including the publisher ID. The JavaScript draws an iframe which contains the script that actually pulls the ads to display.

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx for helpin

    Can php recall data from a mysql database like php can. It would make everything alot easier.
    And how did you get to be software architect marketing guru of the year. I'm curious.

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by desbest View Post
    thx for helpin

    Can php recall data from a mysql database like php can. It would make everything alot easier.
    And how did you get to be software architect marketing guru of the year. I'm curious.
    You mean JavaScript? No, JavaScript runs entirely on the client's browser, so it can't get data from your database. That's the purpose of using JavaScript to draw an iframe: to pass the JavaScript variables to a server-side script that *can* talk to the database.

    SitePoint nominates and votes on member awards annually

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  6. #6
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dan Grossman View Post
    You mean JavaScript? No, JavaScript runs entirely on the client's browser, so it can't get data from your database. That's the purpose of using JavaScript to draw an iframe: to pass the JavaScript variables to a server-side script that *can* talk to the database.
    Are you saying that javascript can send data to a php page to be processed?
    Meaning that the php page does something depending to the variables in the javascript code placed on the members page.

    Therefore, the javascript can get information from a database thanks to the php page.

  7. #7
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    813
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, at least you need a backend scripting sitting there waiting for your javascript application request and return back your variable value in favor of html or xml content.

  8. #8
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You can, but not everyone's browser supports AJAX, and if Google's using iframes to draw their ads... there's probably a reason, right? Perhaps because it's simple to do and works the same in practically all browsers? Why make this harder than it needs to be.

  9. #9
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i've seen an example of javascript pointing to a php document
    Code:
    	<script type="text/javascript" src="http://www.templatehelp.com/codes/pr_search_form.php?pr_code=cF88c6Bw65Uol2wTGgZ7uoP8m0T6KI&layout_id=h1&by_type=1&by_category=1&by_price=1&by_keyword=1&cols=3&rows=20&frname=resultd&bgcolor=&#37;23dfdfdf"> </script>
    So I don't need to learn javascript after all. But maybe I do so I can code this....

  10. #10
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by desbest View Post
    i've seen an example of javascript pointing to a php document
    Code:
    	<script type="text/javascript" src="http://www.templatehelp.com/codes/pr_search_form.php?pr_code=cF88c6Bw65Uol2wTGgZ7uoP8m0T6KI&layout_id=h1&by_type=1&by_category=1&by_price=1&by_keyword=1&cols=3&rows=20&frname=resultd&bgcolor=%23dfdfdf"> </script>
    So I don't need to learn javascript after all.
    That PHP script needs to output javascript code.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •