http://sestud.uv.es/manual.esp/vbscript/vb13.htm?tema="VBSscript"Si invocamos las ocho propiedades de Location:
<HTML>
<HEAD><TITLE>Objetos del IE</TITLE>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Prueba
Document.Write "1 - " & Location.Protocol & "<br>"
Document.Write "2 - " & Location.Href & "<br>"
Document.Write "3 - " & Location.Host & "<br>"
Document.Write "4 - " & Location.HostName & "<br>"
Document.Write "5 - " & Location.Port & "<br>"
Document.Write "6 - " & Location.PathName & "<br>"
Document.Write "7 - " & Location.Search & "<br>"
Document.Write "8 - " & Location.Hash & "<br>"
End Sub
-->
</SCRIPT>
</HEAD>
<BODY OnLoad="Prueba">
</BODY>
</HTML>
Este sería el resultado:
1 - http:
2 - http://sestud.uv.es/manual.esp/vbscript/vb13.htm?tema="VBSscript"
3 - sestud.uv.es
4 - sestud.uv.es
5 -
6 - /manual.esp/vbscript/vb13.htm
7 - ?tema="VBSscript"
8 -
En este ejemplo, se han leido los valores que contienen cada una de las propiedades, pero también puede utilizarse para dar valor a las mismas propiedades. El siguiente ejemplo cambiará el valor que haya en la línea de URL del navegador al pulsar el botón Prueba, e inmediatamente cargará la nueva página:
<HTML>
<HEAD><TITLE>Objetos del IE</TITLE>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Prueba_Location
Location.Href="http://sestud.uv.es/manual.esp/indice.htm"
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="Formulario1">
<INPUT TYPE="Button" NAME="Boton1" VALUE="Prueba" onClick="Prueba_Location">
</FORM>
</BODY>
</HTML>