Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - VBScript function in a .htm page

Reply
 
Old 09-16-2008   #1 (permalink)
ToniS


 
 

VBScript function in a .htm page

I am new to this and do not understand why the below code does not work.
I basically have an .htm page and would like to execute a VBscript function.
I have done this on .asp pages and it works fine. When I test this page, all
that displays for the email address link is "> When I click on this link I
get
the following error. "Cannot find "File://path where I have the .htm
file/%3c%=FormatEmail('. Make sure the path or internet address is correct.

Any suggestions would be greatly appreciated.

NOTE: Below code is not pretty re: A end user creates this page via word,
frontpage, I am not sure... I just added the function part and removed the
hardcoding of the email address.

Thanks
TSharp

<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns="urn:schemas-microsoft-comfficeffice"
xmlns:w="urn:schemas-microsoft-comffice:word"
xmlns:st1="urn:schemas-microsoft-comffice:smarttags"
xmlns="http://www.w3.org/TR/REC-html40">

<SCRIPT LANGUAGE="VBSCRIPT">

Function FormatEmail(Recipient,Mode)

Const conEMHost = "ABCHostName.com"
Const conProtocol1 = "mail"
Const conProtocol2 = "to:"

Select Case Mode
Case 1 ' Return actual email link
FormatEmail = conProtocol1 & conProtocol2 & Recipient & "@" & conEMHost
Case 2 ' Return literal String
FormatEmail = Recipient & "@" & conEMHost
End Select

End Function
</SCRIPT>

<head>

My System SpecsSystem Spec
Old 09-16-2008   #2 (permalink)
krazymike


 
 

Re: VBScript function in a .htm page

Remember that this code runs on the client, so the <% %> server code
won't work. This does:

<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns="urn:schemas-microsoft-comfficeffice"
xmlns:w="urn:schemas-microsoft-comffice:word"
xmlns:st1="urn:schemas-microsoft-comffice:smarttags"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<SCRIPT type="text/vbscript">
Function FormatEmail(Recipient,Mode)
Const conEMHost = "ABCHostName.com"
Const conProtocol1 = "mail"
Const conProtocol2 = "to:"
Select Case Mode
Case 1 ' Return actual email link
FormatEmail = conProtocol1 & conProtocol2 & Recipient & "@" &
conEMHost
Case 2 ' Return literal String
FormatEmail = Recipient & "@" & conEMHost
End Select
End Function
</SCRIPT>
</head>
<body lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>

<script type="text/vbscript">
'msgbox FormatEmail("recruiting",1)
document.write ("<A href=""" & FormatEmail("recruiting",1) & """>" &
FormatEmail("recruiting",2) & "</A>")
</script>
</body>
</html>

ToniS wrote:
Quote:

> I am new to this and do not understand why the below code does not work.
> I basically have an .htm page and would like to execute a VBscript function.
> I have done this on .asp pages and it works fine. When I test this page, all
> that displays for the email address link is "> When I click on this link I
> get
> the following error. "Cannot find "File://path where I have the .htm
> file/%3c%=FormatEmail('. Make sure the path or internet address is correct.
>
> Any suggestions would be greatly appreciated.
>
> NOTE: Below code is not pretty re: A end user creates this page via word,
> frontpage, I am not sure... I just added the function part and removed the
> hardcoding of the email address.
>
> Thanks
> TSharp
>
> <html xmlns:v="urn:schemas-microsoft-com:vml"
> xmlns="urn:schemas-microsoft-comfficeffice"
> xmlns:w="urn:schemas-microsoft-comffice:word"
> xmlns:st1="urn:schemas-microsoft-comffice:smarttags"
> xmlns="http://www.w3.org/TR/REC-html40">
>
> <SCRIPT LANGUAGE="VBSCRIPT">
>
> Function FormatEmail(Recipient,Mode)
>
> Const conEMHost = "ABCHostName.com"
> Const conProtocol1 = "mail"
> Const conProtocol2 = "to:"
>
> Select Case Mode
> Case 1 ' Return actual email link
> FormatEmail = conProtocol1 & conProtocol2 & Recipient & "@" & conEMHost
> Case 2 ' Return literal String
> FormatEmail = Recipient & "@" & conEMHost
> End Select
>
> End Function
> </SCRIPT>
>
> <head>
> .
> .
> .
>
> <body lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>
> .
> .
> .
> <A
> href="<%=FormatEmail("recruiting",1)%>"><%=FormatEmail("recruiting",2)%></A>
> </td>
> </tr>
> </table>
>
> </div>
>
> <p class=MsoNormal><o> </o></p>
>
> </div>
> </body>
> </html>
My System SpecsSystem Spec
Old 09-16-2008   #3 (permalink)
ToniS


 
 

Re: VBScript function in a .htm page


Thanks for responding, I should have remembered the <% was for the server
side (I have a lot to learn!!) I tried what you had and now nothing appears.
I even cut and copied the below code and tried that by itself and I still
ended up with a blank page... I am on IE7, (that should not matter?)



Tsharp

"krazymike" wrote:
Quote:

> Remember that this code runs on the client, so the <% %> server code
> won't work. This does:
>
> <html xmlns:v="urn:schemas-microsoft-com:vml"
> xmlns="urn:schemas-microsoft-comfficeffice"
> xmlns:w="urn:schemas-microsoft-comffice:word"
> xmlns:st1="urn:schemas-microsoft-comffice:smarttags"
> xmlns="http://www.w3.org/TR/REC-html40">
> <head>
> <SCRIPT type="text/vbscript">
> Function FormatEmail(Recipient,Mode)
> Const conEMHost = "ABCHostName.com"
> Const conProtocol1 = "mail"
> Const conProtocol2 = "to:"
> Select Case Mode
> Case 1 ' Return actual email link
> FormatEmail = conProtocol1 & conProtocol2 & Recipient & "@" &
> conEMHost
> Case 2 ' Return literal String
> FormatEmail = Recipient & "@" & conEMHost
> End Select
> End Function
> </SCRIPT>
> </head>
> <body lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>
>
> <script type="text/vbscript">
> 'msgbox FormatEmail("recruiting",1)
> document.write ("<A href=""" & FormatEmail("recruiting",1) & """>" &
> FormatEmail("recruiting",2) & "</A>")
> </script>
> </body>
> </html>
>
> ToniS wrote:
Quote:

> > I am new to this and do not understand why the below code does not work.
> > I basically have an .htm page and would like to execute a VBscript function.
> > I have done this on .asp pages and it works fine. When I test this page, all
> > that displays for the email address link is "> When I click on this link I
> > get
> > the following error. "Cannot find "File://path where I have the .htm
> > file/%3c%=FormatEmail('. Make sure the path or internet address is correct.
> >
> > Any suggestions would be greatly appreciated.
> >
> > NOTE: Below code is not pretty re: A end user creates this page via word,
> > frontpage, I am not sure... I just added the function part and removed the
> > hardcoding of the email address.
> >
> > Thanks
> > TSharp
> >
> > <html xmlns:v="urn:schemas-microsoft-com:vml"
> > xmlns="urn:schemas-microsoft-comfficeffice"
> > xmlns:w="urn:schemas-microsoft-comffice:word"
> > xmlns:st1="urn:schemas-microsoft-comffice:smarttags"
> > xmlns="http://www.w3.org/TR/REC-html40">
> >
> > <SCRIPT LANGUAGE="VBSCRIPT">
> >
> > Function FormatEmail(Recipient,Mode)
> >
> > Const conEMHost = "ABCHostName.com"
> > Const conProtocol1 = "mail"
> > Const conProtocol2 = "to:"
> >
> > Select Case Mode
> > Case 1 ' Return actual email link
> > FormatEmail = conProtocol1 & conProtocol2 & Recipient & "@" & conEMHost
> > Case 2 ' Return literal String
> > FormatEmail = Recipient & "@" & conEMHost
> > End Select
> >
> > End Function
> > </SCRIPT>
> >
> > <head>
> > .
> > .
> > .
> >
> > <body lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>
> > .
> > .
> > .
> > <A
> > href="<%=FormatEmail("recruiting",1)%>"><%=FormatEmail("recruiting",2)%></A>
> > </td>
> > </tr>
> > </table>
> >
> > </div>
> >
> > <p class=MsoNormal><o> </o></p>
> >
> > </div>
> > </body>
> > </html>
>
My System SpecsSystem Spec
Old 09-17-2008   #4 (permalink)
Joe Fawcett


 
 

Re: VBScript function in a .htm page

Works for me, you should check that lines haven't wrapped.
And if you're using XHTML SCRIPT should be script and all attribute values
should be quoted.

--

Joe Fawcett (MVP - XML)

http://joe.fawcett.name

"ToniS" <ToniS@xxxxxx> wrote in message
news:59027F49-520B-40EF-A848-0E700DD14455@xxxxxx
Quote:

>
> Thanks for responding, I should have remembered the <% was for the server
> side (I have a lot to learn!!) I tried what you had and now nothing
> appears.
> I even cut and copied the below code and tried that by itself and I still
> ended up with a blank page... I am on IE7, (that should not matter?)
>
>
>
> Tsharp
>
> "krazymike" wrote:
>
Quote:

>> Remember that this code runs on the client, so the <% %> server code
>> won't work. This does:
>>
>> <html xmlns:v="urn:schemas-microsoft-com:vml"
>> xmlns="urn:schemas-microsoft-comfficeffice"
>> xmlns:w="urn:schemas-microsoft-comffice:word"
>> xmlns:st1="urn:schemas-microsoft-comffice:smarttags"
>> xmlns="http://www.w3.org/TR/REC-html40">
>> <head>
>> <SCRIPT type="text/vbscript">
>> Function FormatEmail(Recipient,Mode)
>> Const conEMHost = "ABCHostName.com"
>> Const conProtocol1 = "mail"
>> Const conProtocol2 = "to:"
>> Select Case Mode
>> Case 1 ' Return actual email link
>> FormatEmail = conProtocol1 & conProtocol2 & Recipient & "@" &
>> conEMHost
>> Case 2 ' Return literal String
>> FormatEmail = Recipient & "@" & conEMHost
>> End Select
>> End Function
>> </SCRIPT>
>> </head>
>> <body lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>
>>
>> <script type="text/vbscript">
>> 'msgbox FormatEmail("recruiting",1)
>> document.write ("<A href=""" & FormatEmail("recruiting",1) & """>" &
>> FormatEmail("recruiting",2) & "</A>")
>> </script>
>> </body>
>> </html>
>>
>> ToniS wrote:
Quote:

>> > I am new to this and do not understand why the below code does not
>> > work.
>> > I basically have an .htm page and would like to execute a VBscript
>> > function.
>> > I have done this on .asp pages and it works fine. When I test this
>> > page, all
>> > that displays for the email address link is "> When I click on this
>> > link I
>> > get
>> > the following error. "Cannot find "File://path where I have the .htm
>> > file/%3c%=FormatEmail('. Make sure the path or internet address is
>> > correct.
>> >
>> > Any suggestions would be greatly appreciated.
>> >
>> > NOTE: Below code is not pretty re: A end user creates this page via
>> > word,
>> > frontpage, I am not sure... I just added the function part and removed
>> > the
>> > hardcoding of the email address.
>> >
>> > Thanks
>> > TSharp
>> >
>> > <html xmlns:v="urn:schemas-microsoft-com:vml"
>> > xmlns="urn:schemas-microsoft-comfficeffice"
>> > xmlns:w="urn:schemas-microsoft-comffice:word"
>> > xmlns:st1="urn:schemas-microsoft-comffice:smarttags"
>> > xmlns="http://www.w3.org/TR/REC-html40">
>> >
>> > <SCRIPT LANGUAGE="VBSCRIPT">
>> >
>> > Function FormatEmail(Recipient,Mode)
>> >
>> > Const conEMHost = "ABCHostName.com"
>> > Const conProtocol1 = "mail"
>> > Const conProtocol2 = "to:"
>> >
>> > Select Case Mode
>> > Case 1 ' Return actual email link
>> > FormatEmail = conProtocol1 & conProtocol2 & Recipient & "@" & conEMHost
>> > Case 2 ' Return literal String
>> > FormatEmail = Recipient & "@" & conEMHost
>> > End Select
>> >
>> > End Function
>> > </SCRIPT>
>> >
>> > <head>
>> > .
>> > .
>> > .
>> >
>> > <body lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>
>> > .
>> > .
>> > .
>> > <A
>> > href="<%=FormatEmail("recruiting",1)%>"><%=FormatEmail("recruiting",2)%></A>
>> > </td>
>> > </tr>
>> > </table>
>> >
>> > </div>
>> >
>> > <p class=MsoNormal><o> </o></p>
>> >
>> > </div>
>> > </body>
>> > </html>
>>

My System SpecsSystem Spec
Old 09-17-2008   #5 (permalink)
ToniS


 
 

Re: VBScript function in a .htm page

Thank you both krazymike and Joe, some of it wrapped and I did not realize
that would cause problems..

THANKS again!!
Tsharp

"Joe Fawcett" wrote:
Quote:

> Works for me, you should check that lines haven't wrapped.
> And if you're using XHTML SCRIPT should be script and all attribute values
> should be quoted.
>
> --
>
> Joe Fawcett (MVP - XML)
>
> http://joe.fawcett.name
>
> "ToniS" <ToniS@xxxxxx> wrote in message
> news:59027F49-520B-40EF-A848-0E700DD14455@xxxxxx
Quote:

> >
> > Thanks for responding, I should have remembered the <% was for the server
> > side (I have a lot to learn!!) I tried what you had and now nothing
> > appears.
> > I even cut and copied the below code and tried that by itself and I still
> > ended up with a blank page... I am on IE7, (that should not matter?)
> >
> >
> >
> > Tsharp
> >
> > "krazymike" wrote:
> >
Quote:

> >> Remember that this code runs on the client, so the <% %> server code
> >> won't work. This does:
> >>
> >> <html xmlns:v="urn:schemas-microsoft-com:vml"
> >> xmlns="urn:schemas-microsoft-comfficeffice"
> >> xmlns:w="urn:schemas-microsoft-comffice:word"
> >> xmlns:st1="urn:schemas-microsoft-comffice:smarttags"
> >> xmlns="http://www.w3.org/TR/REC-html40">
> >> <head>
> >> <SCRIPT type="text/vbscript">
> >> Function FormatEmail(Recipient,Mode)
> >> Const conEMHost = "ABCHostName.com"
> >> Const conProtocol1 = "mail"
> >> Const conProtocol2 = "to:"
> >> Select Case Mode
> >> Case 1 ' Return actual email link
> >> FormatEmail = conProtocol1 & conProtocol2 & Recipient & "@" &
> >> conEMHost
> >> Case 2 ' Return literal String
> >> FormatEmail = Recipient & "@" & conEMHost
> >> End Select
> >> End Function
> >> </SCRIPT>
> >> </head>
> >> <body lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>
> >>
> >> <script type="text/vbscript">
> >> 'msgbox FormatEmail("recruiting",1)
> >> document.write ("<A href=""" & FormatEmail("recruiting",1) & """>" &
> >> FormatEmail("recruiting",2) & "</A>")
> >> </script>
> >> </body>
> >> </html>
> >>
> >> ToniS wrote:
> >> > I am new to this and do not understand why the below code does not
> >> > work.
> >> > I basically have an .htm page and would like to execute a VBscript
> >> > function.
> >> > I have done this on .asp pages and it works fine. When I test this
> >> > page, all
> >> > that displays for the email address link is "> When I click on this
> >> > link I
> >> > get
> >> > the following error. "Cannot find "File://path where I have the .htm
> >> > file/%3c%=FormatEmail('. Make sure the path or internet address is
> >> > correct.
> >> >
> >> > Any suggestions would be greatly appreciated.
> >> >
> >> > NOTE: Below code is not pretty re: A end user creates this page via
> >> > word,
> >> > frontpage, I am not sure... I just added the function part and removed
> >> > the
> >> > hardcoding of the email address.
> >> >
> >> > Thanks
> >> > TSharp
> >> >
> >> > <html xmlns:v="urn:schemas-microsoft-com:vml"
> >> > xmlns="urn:schemas-microsoft-comfficeffice"
> >> > xmlns:w="urn:schemas-microsoft-comffice:word"
> >> > xmlns:st1="urn:schemas-microsoft-comffice:smarttags"
> >> > xmlns="http://www.w3.org/TR/REC-html40">
> >> >
> >> > <SCRIPT LANGUAGE="VBSCRIPT">
> >> >
> >> > Function FormatEmail(Recipient,Mode)
> >> >
> >> > Const conEMHost = "ABCHostName.com"
> >> > Const conProtocol1 = "mail"
> >> > Const conProtocol2 = "to:"
> >> >
> >> > Select Case Mode
> >> > Case 1 ' Return actual email link
> >> > FormatEmail = conProtocol1 & conProtocol2 & Recipient & "@" & conEMHost
> >> > Case 2 ' Return literal String
> >> > FormatEmail = Recipient & "@" & conEMHost
> >> > End Select
> >> >
> >> > End Function
> >> > </SCRIPT>
> >> >
> >> > <head>
> >> > .
> >> > .
> >> > .
> >> >
> >> > <body lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>
> >> > .
> >> > .
> >> > .
> >> > <A
> >> > href="<%=FormatEmail("recruiting",1)%>"><%=FormatEmail("recruiting",2)%></A>
> >> > </td>
> >> > </tr>
> >> > </table>
> >> >
> >> > </div>
> >> >
> >> > <p class=MsoNormal><o> </o></p>
> >> >
> >> > </div>
> >> > </body>
> >> > </html>
> >>
>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
VBscript Array Split Function VB Script
digital certified in a vbscript function VB Script
VBScript procedure and function calls VB Script
HTML and VBscript printer management page VB Script
VBScript to search LDAP from Excel function? VB Script


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46