Click to See Complete Forum and Search --> : VBScript to Javascript
kryogenic
04-16-2003, 05:21 PM
A problem...in a forum...uh-oh!
Here it is:
I have been thinking myself clever by writing all unneccessary code with VBScript and keeping it in a seperate this.vbs file. That way I could load it into the HTML without it being parsed, thus allowing me to create a Robots.txt file to hide the external file from Search Engine Spiders.
Sounds brilliant from an SEO point of view. Unfortuanately VBScript doesn't work in Netscape unless a paid-for plug-in is installed or is run server-side(not likely on most unix). Nice catch for those 10% of baby boomers using it.
I'm not too great at javascript. the conept I am trying unsuccessfully to translate is:
####seperate .vbs file####
Sub text()
DOCUMENT.WRITE "Hello World"
end Sub
***************************
And somewhere in the document you want to call the text write :
<script language="VBScript">
call text()
</script>
seems simple enough. yet I can't seem to translate this concept into javascript to bring into the document.
yes, I have gone the
}
document.write("<H1>Hello World</H1>");
}
then calling it into a
<BODY onLoad="writingjavascript()">
or
<Span(or Div) onClick="writingjavascript()"></div>
both within the HTML and in a seperate file.
Always problems....
Once this is figured out(I know I am close somewhere....)
then I can do the same with image maps, etc leaving only the body content and copywriting for the Spiders to see.
If anyone has a sample of this concept I could use as a guide....much appreciated. Perhaps a sample with
<table>
<tr>
<td>somthing</td>
<td>something else</td>
</tr>
<tr>
leaving the remaining tags in the html to be closed there. Being brought in with
<script language="JavaScript" src="this.js"></script>
Help with this and I will be more then glad to educate on Search Engine Optimization in exchange
kryogenic
04-16-2003, 06:04 PM
Thank you for the quick response.
Perhaps I should add some clarification.
I understand reserved words/terms and so on, including "this" but for simple explanatory purposes...sigh..never mind.
ok. VBScript is not case sensitive, you are correct. JavaScript is, again, you are correct.
My problem is in the call to the script/function.
an example using an event would be :
<html>
<head>
<title>Hmmm</title>
<script language="JavaScript">
<!--
Function information(){
document.write ("Funny world" + "<br>");
}
//-->
</script>
</head>
<body>
<span align="center" onClick="information()" style="cursor:hand;">
<h2>General information</h2>
</span>
</body>
</html>
can you see the functionality I am going for? In practical terms I would like to be able to write tables and cell content in a .js file. Ideally, once it is working in the HTML extracting it is easy.
kryogenic
04-16-2003, 06:20 PM
Just to avoid being condescended again these are the exact two I have been working with:
VBScript file label =topimage.vbs
############
Sub topimage()
Document.Write "<TABLE width=790 height=527 align=left >"
Document.Write "<TR>"
Document.Write "<TD align=center width=130 height=100% rowspan=3 valign=top background=Images/rs.gif>"
Document.Write "<img src=Images/cars.jpg>" & "<BR>" & "<BR>" & "<BR>" & "<BR>" & "<BR>" & "<BR>" & "<BR>" & "<BR>"
Document.Write "<a href=default.html target= _self>CMC Home</a>" & "<BR>" & "<BR>"
Document.Write "<a href=about_missing_children.html target= _self>About Missing Children</a>" & "<BR>" & "<BR>"
Document.Write "<a href=how_to_donate.html target=_self>How To Donate</a>" & "<BR>" & "<BR>"
Document.Write "<a href=application.html target= _self>Donation Form</a>" & "<BR>" & "<BR>"
Document.Write "<a href=tax_benefit.html target= _self>Tax Deduction</a>" & "<BR>" & "<BR>"
Document.Write "<a href=faq.html target=_self>Frequent Questions</a>" & "<BR>" & "<BR>"
Document.Write "<a href=contact.html target=_self>Contact Us</a>" & "<BR>" & "<BR>"
Document.Write "<a href=site_map.html target=_self>Site Map</a>" & "<BR>" & "<BR>"
Document.Write "</TD>"
Document.Write "<TD width=610 height=120 align=center valign=top>"
Document.Write "<IMG src=Images/Logo.gif>"
Document.Write "</TD>"
Document.Write "</TR>"
Document.Write "<TR>"
end sub
############
JavaScript file label = topimage.js
############
<!--
function topimage(){
document.write ("<TABLE width=790 height=527 align=left >");
document.write ("<TR>");
document.write ("<TD align=center width=130 height=100% rowspan=3 valign=top
background=Images/rs.gif>");
document.write ("<img src=Images/cars.jpg>" + "<BR>" + "<BR>" + "<BR>" + "<BR>" + "<BR>" +
"<BR>" + "<BR>" + "<BR>");
document.write ("<a href=default.html target= _self>CMC Home</a>" + "<BR>" + "<BR>");
document.write ("<a href=about_missing_children.html target= _self>About Missing
Children</a>" + "<BR>" + "<BR>");
document.write ("<a href=how_to_donate.html target=_self>How To Donate</a>" + "<BR>" +
"<BR>");
document.write ("<a href=application.html target= _self>Donation Form</a>" + "<BR>" +
"<BR>");
document.write ("<a href=tax_benefit.html target= _self>Tax Deduction</a>" + "<BR>" +
"<BR>");
document.write ("<a href=faq.html target=_self>Frequent Questions</a>" + "<BR>" + "<BR>");
document.write ("<a href=contact.html target=_self>Contact Us</a>" + "<BR>" + "<BR>");
document.write ("<a href=site_map.html target=_self>Site Map</a>" + "<BR>" + "<BR>");
document.write ("</TD>");
document.write ("<TD width=610 height=120 align=center valign=top>");
document.write ("<IMG src=Images/Logo.gif>");
document.write ("</TD>");
document.write ("</TR>");
document.write ("<TR>");
}
//-->
###############
A little messy..but what can you expect from note pad?
kryogenic
04-16-2003, 08:26 PM
I am unable to bring it into the HTML without recieving errors.
You can see what I am trying to do, but what I am unable to do is call the function from the HTML document.
Before you ask, yes I have tried the simple calls like
Onload
Onclick,etc
if for no other reason then to get SOMETHING to display.
I need help bringing it into the page so it merges with the rest of the HTML but without visually removing the HTML as is done with:
function information(){
document.getElementById("divID").innerHTML = "Funny world" + "<br>";
}
kryogenic
04-16-2003, 09:02 PM
oh this is becoming fun.
No. not quite. I don't want to display the HTML itself.
I want javascript to write the html, the content within the html and merge into the document so visually it appears as though
it was written in HTML when..
.... when in fact it was a section of the body content written in javascript that was brought in with a
<script Language="javascript" src=""> in the head of the HTML.
kryogenic
04-16-2003, 09:30 PM
I tried using it in the format I would be using it for under a "test" pretense.
the table idea works, but additional HTML does not appear.
I am hoping it is just the I am doing it or the way I am explaining it to the forum that is making this so difficult.
Maybe it just doesn't like being created in notepad, Dreamweaver, or InterDev...dunno
Anyways, here is the modified script I used to test with:
<html>
<head>
<title>Hmm...</title>
<script language="JavaScript">
<!--
function information(){
document.getElementById("happy").innerHTML = ("<Table border='1'><TR><TD><H1>Hello World</H1></TD>"); }
<html>
<head>
<title>Hmm...</title>
<script language="JavaScript">
<!--
function information(){
document.getElementById("happy").innerHTML = ("<Table border='1'><TR><TD><H1>Hello World</H1></TD>"); }
//-->
</script>
</head>
<BODY id="happy" onLoad="information()">
<BODY id="happy" onLoad="information()">
</tr>
</table>
<p>Welcome</p>
<h2>This is the third block of text</h2>
</body>
</html>
kryogenic
04-16-2003, 09:50 PM
yep. I am officially beating my head against a wall.
There is someting I am not getting here. In the samples you gave there is no function call(which seems to be the extent of my JavaScript knowledge).
There is a declaration within the script for the ID. That is now beyond my knowledge for Java.
Is there a way of using a function call to make this work as was being done in the body tag?
kryogenic
04-16-2003, 10:21 PM
I would like to thank you for your patience thus far.
It would appear what I am trying to do is currently out of my league for javascript.
It seems so simple in VBScript. Heck, it works with VBScript.
The way you are explaining it makes me think of ASP with the variable settings for the table--dynamically running from a recordset. Unfortuanately this is much less complex and only requires a static function.
What it boils down to is that I want to write a little bit of HTML in a seperate .js file that I can bring in to my HTML by calling it where it is needed as is seen with the VBScript example at the top.
The purpose is not for a Dynamic web page. It is simply a way of keeping as much code invisible to Search Engine Spiders as possible so that all they will see will be the body text which is still HTML. The Javascript file basically hides only the tags I don't need them to see.
khaki
04-16-2003, 10:32 PM
aren't the contents of server-side includes invisible to search engine spiders?
<!-- #Include file'"hiddenFromView.inc" -->
i don't really know... just assuming :rolleyes:
... but if so... there you go (and if not... :rolleyes: ).
(are SSI available to you?)
if not... what about iframes?
(okay... i've got nothing left :rolleyes: )
;) k
kryogenic
04-16-2003, 10:38 PM
Spiders. The answer is all about the little bugs.
Search Engine Spiders only pay attention to n() amount of text on the web page. So the closer the text you want to get noticed is to the body tag the better the rankings are on the SE's.
If you have a script in the head tags, or anywhere really, it is counted within that n() count. Spiders have difficulty seperating <script></script> tags from the content as things are now. That may change down the road, but for now...
From an SEO view keeping scripts in a seperate file helps the ranking of a web page on the search engines. It keeps the keyword-rich text closer to the spiders. As far as they are concerned the higher something is on a page the more important it is.
There are other variables for their point/ranking system but this one is a certain fact.
Perhaps you understand why doing this script is important for me.
kryogenic
04-16-2003, 10:43 PM
Khaki,
you follow a similar thought path to most web designers.
#include files get parsed on to the page so it gets seen regardless.
What I'm going for here is a way to hide it....
Robots.txt is the best way to target what a SE spider sees as far as files go.
the only way I know of that isn't processed server-side to keep a file from being parsed is by using the <script/style src "">
Good thinking though, and thanks
kryogenic
04-16-2003, 10:47 PM
Exactly Dave.
The reason I am following a different method is because
Netscape Navigator doesn't support VBScript.
So the same thing needs to able to be done with JavaScript.
When I am lucky enough to get a client running ASP friendly servers then I'll be using the VBScript because it's parsed at the server so Netscape can read it.
kryogenic
04-16-2003, 10:59 PM
Ok. Problem solved. Dave, thank you. If there is anything I can do please ask. If I know the answer...
To others reading the posts this is the solution for your own viewing:
####This is what is in your test.js file####
<!--
document.write ("<Table border='1'><TR><TD><H1>Hello
World</H1></TD>");
//-->
####This is what is in your html file####
<html>
<head>
<title>Hmm...</title>
</head>
<BODY>
<p>Welcome</p>
<script language="javascript" src="test.js" type="text/javascript"></script>
</tr>
</table>
<h2>This is the third block of text</h2>
</body>
</html>
##########
Why is it that the simple solutions are always the ones that are the least obvious.
Suppose that's why Beta testing for web pages and programs are done by other people.
kryogenic
04-16-2003, 11:08 PM
Thanks again Dave.
Your a very patient person.
If nothing else I hope you got to learn a bit about search engines through all this.