SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru ripcurlksm's Avatar
    Join Date
    Aug 2004
    Location
    San Clemente, CA
    Posts
    859
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Print clean HTML

    I have a javascript file that I am using to pull in links that is stored in a .js file.

    HTML Code:
    <script src="http://someserver.com/script.js"></script>
    --------------------
    script.js
    --------------------
    Code:
    document.write("<a href=\"http://yahoo.com">Yahoo.com</a><p>");
    document.write("<a href=\"http://google.com">Google.com</a><p>");
    document.write("<a href=\"http://hotbot.com">Hotbot.com</a><p>");

    This is working great however if you look at the HTML source of the page it shows the above script src call. Is there anyway to have the source code actually print this in the HTML on the page:
    HTML Code:
    <a href="http://yahoo.com">Yahoo.com</a><p>
    <a href="http://google.com">Google.com</a><p>
    <a href="http://hotbot.com">Hotbot.com</a><p>
    Instead of this:

    HTML Code:
    <script src="http://someserver.com/script.js"></script>

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From what I've gathered in learning javascript so far, the answer is no you can't do that with javascript because it's clientside. You need something like PHP that works on the server side, so the user doesn't see what's "underneath" since it's all happening on the server.


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
  •