Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Nov 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Display Text In Page From URL

    I have a question for any javascript programmers that know how to do the following.

    I would like to display the text from my URL page link in different parts of my web page.

    So if I have a page link like the following:

    Code:
    http://www.domainname.com/keyword-name.html
    I can then use that keyword name in my page content as follows:

    <p>This is a paragraph to show how I would like to display this keyword name here in my content. Today is a great day and I appreciate anyone who can figure out how to display this keyword name. Thanks again to anyone who can help on this idea. I hope I have explained my idea for my keyword name in page content.</p>

    Thanks again

  • #2
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,718
    Thanks
    0
    Thanked 240 Times in 235 Posts
    Hi there designguru,

    does this help...
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <style type="text/css">
    #theLink {
        color:#000;
        background-color:#fff;
     }
    #thePar {
        width:700px;
        padding:10px;
        border:1px solid #999;
        text-align:justify;
        margin:20px auto;
     }
    .keyword {
        font-weight:bold;
        color:#600;
        background-color:#fff;    
     }
    </style>
    
    <script type="text/javascript">
    window.onload=function() {
       spn=document.getElementById('thePar').getElementsByTagName('span');
    for(c=0;c<spn.length;c++) {
       theWord=document.getElementById('theLink').href;
       theWord=theWord.split('/')[3].split('.')[0];
       spn[c].firstChild.nodeValue=theWord;
      }
     }
    
    </script>
    
    </head>
    <body>
    
    <ul>
    <li><a id="theLink" href="http://www.domainname.com/keyword-name.html">http://www.domainname.com/keyword-name.html</a></li>
    </ul>
    
    <p id="thePar">
    This is a paragraph to show how I would like to display this <span class="keyword">&nbsp</span> here in my content. 
    Today is a great day and I appreciate anyone who can figure out how to display this <span class="keyword">&nbsp</span>. 
    Thanks again to anyone who can help on this idea. I hope I have explained my idea for my <span class="keyword">&nbsp</span> 
    in page content.
    </p>
    
    </body>
    </html>
    coothead

  • #3
    New Coder
    Join Date
    Nov 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    That Works Great But A Couple Of Issues

    Thanks for all your help...your script works great but I guess there are a couple of issues that I still don't have worked out and it might just be that I can't do what I am wanting to do for this client.

    The client wants a website that is seo friendly...They sell products for a company that uses javascript to pull the products into the page and display the inventory for them. So for seo I have created a mod rewrite that can take the url string from the following and convert it to the following.

    Original URL:

    Code:
    ResultsGeneral.html?stype=0&kwds=keyword%20keyword
    My Mod Rewrite URL:

    Code:
    keyword-keyword.html
    Well as you know there is no way of having any rich content in those pages pertaining to that keyword for the page to ever rank or maybe even get indexed. So my imagination wanted to have a preformatted paragraph that could just pull that url Keyword-keyword into the page so that the serps would see that each of the hundreds of product pages have good content and have the keyword throughout the text content.

    So the first problem is that I see you have formatted it to work off of me actually putting the url in the page and then it read from that instead of actually reading from the url itself...I can't create thousands of pages for them for each product...I also see that when you view the source of the page and the search engines spider the page, they just see <span class="keyword">&nbsp</span> and not the actual word itself...so it does no benefit.

    I know that PHP is the ideal way to go with this but they can't use php because they have everything from the past few years in html format and will lose all there indexed pages etc...plus the serps recognize php as dynamic and kind of defeats the purpose anyway. I am not that familiar with Javascript and I might just be dreaming of this being possible...If so I apologize.

    If you know of a solution that maybe uses xml or something that will let me do this and keep the html extension I am up for anything at this point.

    Thanks again.

  • #4
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    are you wanting this to do it for the url of the page, or a link in the page?

    sounds to me like you wnat the page to load and based on what the url of that page is it writes the keywords into the page.

    lemme know if this is it.
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #5
    New Coder
    Join Date
    Nov 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Yes This is Correct

    Yes Brandon you are exactly correct...sorry if I wasn't clear earlier.

    I would also like it to print that keyword-name without the dashes in it in the page. So it says keyword name in the paragraph instead of keyword-name.

    Your help is greatly appreciated.

  • #6
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    the below link is to another thread that i replied to. it deals with something similar. it should point you in the right direction.


    http://www.codingforums.com/showthread.php?t=100579
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.


  •  

    Posting Permissions

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