Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Open new browser window in vbscript.net

Reply
Thread Tools

Open new browser window in vbscript.net

 
 
smokeyd
Guest
Posts: n/a
 
      12-21-2006
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.

 
Reply With Quote
 
 
 
 
John Timney \(MVP\)
Guest
Posts: n/a
 
      12-21-2006
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=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>

--
--
Regards

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


"smokeyd" <> wrote in message
news: 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.
>



 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      12-21-2006
"John Timney (MVP)" <> wrote in message
news:. uk...

Hi John,

> scriptString = "<script language=JavaScript> function 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...


 
Reply With Quote
 
John Timney \(MVP\)
Guest
Posts: n/a
 
      12-21-2006
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" <> wrote in message
news:...
> "John Timney (MVP)" <> wrote in message
> news:. uk...
>
> Hi John,
>
>> scriptString = "<script language=JavaScript> function 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...
>



 
Reply With Quote
 
John Timney \(MVP\)
Guest
Posts: n/a
 
      12-21-2006
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)" <> wrote in message
news:. 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" <> wrote in message
> news:...
>> "John Timney (MVP)" <> wrote in message
>> news:. uk...
>>
>> Hi John,
>>
>>> scriptString = "<script language=JavaScript> function 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...
>>

>
>



 
Reply With Quote
 
smokeyd
Guest
Posts: n/a
 
      12-21-2006

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)" <> wrote in message
> news:. 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" <> wrote in message
> > news:...
> >> "John Timney (MVP)" <> wrote in message
> >> news:. uk...
> >>
> >> Hi John,
> >>
> >>> scriptString = "<script language=JavaScript> function 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..

 
Reply With Quote
 
Jon Paal
Guest
Posts: n/a
 
      12-21-2006
http://www.dotnetjohn.com/articles.aspx?articleid=88





"smokeyd" <> wrote in message news: 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.
>



 
Reply With Quote
 
John Timney \(MVP\)
Guest
Posts: n/a
 
      12-21-2006
Change your hyperlink declaration to:

<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="javascriptoClick()"> 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" <> wrote in message
news: 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("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)" <> wrote in message
>> news:. 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" <> wrote in message
>> > news:...
>> >> "John Timney (MVP)" <> wrote in message
>> >> news:. uk...
>> >>
>> >> Hi John,
>> >>
>> >>> scriptString = "<script language=JavaScript> function
>> >>> 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..
>



 
Reply With Quote
 
Alexander Higgins
Guest
Posts: n/a
 
      12-21-2006
John Timney (MVP) wrote:
>>Change your hyperlink declaration to:
>><asp:HyperLink ID="HyperLink1" runat="server"
>>NavigateUrl="javascriptoClick()"> 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

 
Reply With Quote
 
John Timney \(MVP\)
Guest
Posts: n/a
 
      12-22-2006
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" <> wrote in message
news: ps.com...
> John Timney (MVP) wrote:
>>>Change your hyperlink declaration to:
>>><asp:HyperLink ID="HyperLink1" runat="server"
>>>NavigateUrl="javascriptoClick()"> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use an asp:button to create a new browser window and output contents to new window =?Utf-8?B?Tm92aWNl?= ASP .Net 2 06-09-2004 10:54 PM
How do I open a new normal (full sized) browser window form a small "pop-up" window? Shiperton Henethe HTML 17 05-21-2004 07:36 AM
window.open() doesn't open new Window in Opera PC HUA Javascript 2 05-19-2004 02:29 AM
Need to open a new browser window, not a new window Gordon ASP General 3 04-16-2004 10:46 PM
Session problem with new IE browser window from window.open() raj Javascript 0 04-07-2004 09:08 PM



Advertisments
 



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 47 48 49 50 51 52 53 54 55 56 57