472,096 Members | 1,242 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 software developers and data experts.

Open new browser window in vbscript.net

hi,

can anyone tell me how to open a link in a new browser window in
vbscript.net. i am looking to be able to set the properties such as
size, menu bar, scroll bar etc. or alternativelly is there a simple
way to do this in visual web developer?

many thanks in advance for your help.

Dec 21 '06 #1
9 3069
Heres an example aspx page for you that shows you how to do it in vb.net.
This works in VWD.

<script runat="server">
Sub Page_Load( sender as Object,e as EventArgs)

Dim scriptString As String
scriptString = "<script language=JavaScriptfunction DoClick() {"
scriptString +=
"window.open('http://www.mvps.org','MyWindow','width=500,height=500');} <"
scriptString += "/"
scriptString += "script>"

If (Not ClientScript.IsClientScriptBlockRegistered("Client Script"))
Then
ClientScript.RegisterClientScriptBlock(Me.GetType( ),
"ClientScript", scriptString)
End If

End Sub

</script>

<html>
<body topmargin="20" leftmargin="10">
<form id="myForm" runat="server">
<input type="button" value="ClickMe" onclick="DoClick()">
</form>
</body>
</html>

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"smokeyd" <to********@umbro.co.ukwrote in message
news:11*********************@79g2000cws.googlegrou ps.com...
hi,

can anyone tell me how to open a link in a new browser window in
vbscript.net. i am looking to be able to set the properties such as
size, menu bar, scroll bar etc. or alternativelly is there a simple
way to do this in visual web developer?

many thanks in advance for your help.

Dec 21 '06 #2
"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:TO******************************@eclipse.net. uk...

Hi John,
scriptString = "<script language=JavaScriptfunction DoClick() {"
That syntax is deprecated now, and won't produce XHTML-compliant markup.

Use this instead:

scriptString = "<script type=\"text/javascript\"function DoClick() {"

Mark

P.S. Not a problem if you don't need cross-browser compatibility... ;-)
Dec 21 '06 #3
fair comment.....I'll change the source example so next time I post it its
covered :)
--
Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:um**************@TK2MSFTNGP04.phx.gbl...
"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:TO******************************@eclipse.net. uk...

Hi John,
> scriptString = "<script language=JavaScriptfunction DoClick() {"

That syntax is deprecated now, and won't produce XHTML-compliant markup.

Use this instead:

scriptString = "<script type=\"text/javascript\"function DoClick() {"

Mark

P.S. Not a problem if you don't need cross-browser compatibility... ;-)

Dec 21 '06 #4
Just for clarity in the thread - for VB.NET the code is
scriptString = "<script type=""text/javascript""function DoClick() {"

Full example below:
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog

<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load( sender as Object,e as EventArgs)
Dim scriptString As String
scriptString = "<script type=""text/javascript""function DoClick()
{"
scriptString +=
"window.open('http://www.mvps.org','MyWindow','width=500,height=500');} <"
scriptString += "/"
scriptString += "script>"

If (Not ClientScript.IsClientScriptBlockRegistered("Client Script"))
Then
ClientScript.RegisterClientScriptBlock(Me.GetType( ),
"ClientScript", scriptString)
End If
End Sub
</script>

<html>
<body topmargin="20" leftmargin="10">
<form id="myForm" runat="server">
<input type="button" value="ClickMe" onclick="DoClick()">
</form>
</body>
</html>

"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:dI******************************@eclipse.net. uk...
fair comment.....I'll change the source example so next time I post it its
covered :)
--
Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:um**************@TK2MSFTNGP04.phx.gbl...
>"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:TO******************************@eclipse.net .uk...

Hi John,
>> scriptString = "<script language=JavaScriptfunction DoClick()
{"

That syntax is deprecated now, and won't produce XHTML-compliant markup.

Use this instead:

scriptString = "<script type=\"text/javascript\"function DoClick() {"

Mark

P.S. Not a problem if you don't need cross-browser compatibility... ;-)


Dec 21 '06 #5

John Timney (MVP) wrote:
Just for clarity in the thread - for VB.NET the code is
scriptString = "<script type=""text/javascript""function DoClick() {"

Full example below:
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog

<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load( sender as Object,e as EventArgs)
Dim scriptString As String
scriptString = "<script type=""text/javascript""function DoClick()
{"
scriptString +=
"window.open('http://www.mvps.org','MyWindow','width=500,height=500');} <"
scriptString += "/"
scriptString += "script>"

If (Not ClientScript.IsClientScriptBlockRegistered("Client Script"))
Then
ClientScript.RegisterClientScriptBlock(Me.GetType( ),
"ClientScript", scriptString)
End If
End Sub
</script>

<html>
<body topmargin="20" leftmargin="10">
<form id="myForm" runat="server">
<input type="button" value="ClickMe" onclick="DoClick()">
</form>
</body>
</html>

"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:dI******************************@eclipse.net. uk...
fair comment.....I'll change the source example so next time I post it its
covered :)
--
Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:um**************@TK2MSFTNGP04.phx.gbl...
"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:TO******************************@eclipse.net. uk...

Hi John,

scriptString = "<script language=JavaScriptfunction DoClick()
{"

That syntax is deprecated now, and won't produce XHTML-compliant markup.

Use this instead:

scriptString = "<script type=\"text/javascript\"function DoClick() {"

Mark

P.S. Not a problem if you don't need cross-browser compatibility... ;-)
thanks for all of the help. the code needed a few little tweaks but
works great:

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim scriptString As String
scriptString = "<script type=""text/javascript""function
DoClick() {"
scriptString +=
"window.open('popup.aspx','MyWindow','width=500,he ight=500');}<"
scriptString += "/"
scriptString += "script>"
If (Not
ClientScript.IsClientScriptBlockRegistered("Client Script")) Then
ClientScript.RegisterClientScriptBlock(Me.GetType( ),
"ClientScript", scriptString)
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:HyperLink ID="HyperLink1" runat="server"
OnClick="DoClick()" NavigateUrl="#"HyperLink</asp:HyperLink></div>
</form>
</body>
</html>

however visual web developer gives an error saying onclick is not a
valid attribute of element 'hyperlink' but seems to work okay anyway..

Dec 21 '06 #6
http://www.dotnetjohn.com/articles.aspx?articleid=88

"smokeyd" <to********@umbro.co.ukwrote in message news:11*********************@79g2000cws.googlegrou ps.com...
hi,

can anyone tell me how to open a link in a new browser window in
vbscript.net. i am looking to be able to set the properties such as
size, menu bar, scroll bar etc. or alternativelly is there a simple
way to do this in visual web developer?

many thanks in advance for your help.

Dec 21 '06 #7
Change your hyperlink declaration to:

<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="javascript:DoClick()"HyperLink</asp:HyperLink>

and your warning should go away.....
Regards
John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"smokeyd" <to********@umbro.co.ukwrote in message
news:11*********************@48g2000cwx.googlegrou ps.com...
>
John Timney (MVP) wrote:
>Just for clarity in the thread - for VB.NET the code is
scriptString = "<script type=""text/javascript""function DoClick() {"

Full example below:
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog

<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load( sender as Object,e as EventArgs)
Dim scriptString As String
scriptString = "<script type=""text/javascript""function
DoClick()
{"
scriptString +=
"window.open('http://www.mvps.org','MyWindow','width=500,height=500');} <"
scriptString += "/"
scriptString += "script>"

If (Not
ClientScript.IsClientScriptBlockRegistered("Clien tScript"))
Then
ClientScript.RegisterClientScriptBlock(Me.GetType( ),
"ClientScript", scriptString)
End If
End Sub
</script>

<html>
<body topmargin="20" leftmargin="10">
<form id="myForm" runat="server">
<input type="button" value="ClickMe" onclick="DoClick()">
</form>
</body>
</html>

"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:dI******************************@eclipse.net .uk...
fair comment.....I'll change the source example so next time I post it
its
covered :)
--
Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:um**************@TK2MSFTNGP04.phx.gbl...
"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:TO******************************@eclipse.net .uk...

Hi John,

scriptString = "<script language=JavaScriptfunction
DoClick()
{"

That syntax is deprecated now, and won't produce XHTML-compliant
markup.

Use this instead:

scriptString = "<script type=\"text/javascript\"function DoClick()
{"

Mark

P.S. Not a problem if you don't need cross-browser compatibility...
;-)

thanks for all of the help. the code needed a few little tweaks but
works great:

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim scriptString As String
scriptString = "<script type=""text/javascript""function
DoClick() {"
scriptString +=
"window.open('popup.aspx','MyWindow','width=500,he ight=500');}<"
scriptString += "/"
scriptString += "script>"
If (Not
ClientScript.IsClientScriptBlockRegistered("Client Script")) Then
ClientScript.RegisterClientScriptBlock(Me.GetType( ),
"ClientScript", scriptString)
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:HyperLink ID="HyperLink1" runat="server"
OnClick="DoClick()" NavigateUrl="#"HyperLink</asp:HyperLink></div>
</form>
</body>
</html>

however visual web developer gives an error saying onclick is not a
valid attribute of element 'hyperlink' but seems to work okay anyway..

Dec 21 '06 #8
John Timney (MVP) wrote:
>>Change your hyperlink declaration to:
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="javascript:DoClick()"HyperLink</asp:HyperLink>

or..... if you want to use the onlclick event in page_load add this:

HyperLink1.attributes.add("onclick", "DoClick()")

Alexander Higgins
http://www.affordablewebdesignsinc.com

Dec 21 '06 #9
Yes, you can do that of course.

The hyperlink declaration should be changed to:

<asp:HyperLink ID="HyperLink1" NavigateUrl="#" runat="server" >
HyperLink</asp:HyperLink>

A quirk with using attributes.add - If you dont set the NavigateUrl property
and dont style it you will get a plain old clickable word.

Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"Alexander Higgins" <al************@hotmail.comwrote in message
news:11*********************@79g2000cws.googlegrou ps.com...
John Timney (MVP) wrote:
>>>Change your hyperlink declaration to:
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="javascript:DoClick()"HyperLink</asp:HyperLink>


or..... if you want to use the onlclick event in page_load add this:

HyperLink1.attributes.add("onclick", "DoClick()")

Alexander Higgins
http://www.affordablewebdesignsinc.com

Dec 22 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Paul Eaton | last post: by
6 posts views Thread by n2K | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.