...

View Full Version : Display Text In Page From URL



designguru
12-01-2006, 04:53 PM
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:


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

coothead
12-01-2006, 06:15 PM
Hi there designguru,

does this help...

<!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

designguru
12-01-2006, 08:14 PM
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:


ResultsGeneral.html?stype=0&kwds=keyword%20keyword

My Mod Rewrite URL:


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.

brandonH
12-02-2006, 12:18 AM
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.

designguru
12-02-2006, 12:51 AM
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.

brandonH
12-02-2006, 08:50 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum