![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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-com ffice ffice"xmlns:w="urn:schemas-microsoft-com ffice:word"xmlns:st1="urn:schemas-microsoft-com ffice: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 Specs![]() |
| | #2 (permalink) |
| | 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-com ffice ffice"xmlns:w="urn:schemas-microsoft-com ffice:word"xmlns:st1="urn:schemas-microsoft-com ffice: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-com ffice ffice"> xmlns:w="urn:schemas-microsoft-com ffice:word"> xmlns:st1="urn:schemas-microsoft-com ffice: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 Specs![]() |
| | #3 (permalink) |
| | 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-com ffice ffice"> xmlns:w="urn:schemas-microsoft-com ffice:word"> xmlns:st1="urn:schemas-microsoft-com ffice: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-com ffice ffice"> > xmlns:w="urn:schemas-microsoft-com ffice:word"> > xmlns:st1="urn:schemas-microsoft-com ffice: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 Specs![]() |
| | #4 (permalink) |
| | 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-com ffice ffice">> xmlns:w="urn:schemas-microsoft-com ffice:word">> xmlns:st1="urn:schemas-microsoft-com ffice: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-com ffice ffice">> > xmlns:w="urn:schemas-microsoft-com ffice:word">> > xmlns:st1="urn:schemas-microsoft-com ffice: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 Specs![]() |
| | #5 (permalink) |
| | 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-com ffice ffice"> >> xmlns:w="urn:schemas-microsoft-com ffice:word"> >> xmlns:st1="urn:schemas-microsoft-com ffice: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-com ffice ffice"> >> > xmlns:w="urn:schemas-microsoft-com ffice:word"> >> > xmlns:st1="urn:schemas-microsoft-com ffice: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 Specs![]() |
![]() |
| 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 | |||