473,786 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3156
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=JavaSc riptfunction DoClick() {"
scriptString +=
"window.open('h ttp://www.mvps.org',' MyWindow','widt h=500,height=50 0');}<"
scriptString += "/"
scriptString += "script>"

If (Not ClientScript.Is ClientScriptBlo ckRegistered("C lientScript"))
Then
ClientScript.Re gisterClientScr iptBlock(Me.Get Type(),
"ClientScri pt", scriptString)
End If

End Sub

</script>

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

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"smokeyd" <to********@umb ro.co.ukwrote in message
news:11******** *************@7 9g2000cws.googl egroups.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.ukwr ote in message
news:TO******** *************** *******@eclipse .net.uk...

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

Use this instead:

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

Mark

P.S. Not a problem if you don't need cross-browser compatibility.. . ;-)
Dec 21 '06 #3
fair comment.....I'l l 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**@markNOSPA Mrae.comwrote in message
news:um******** ******@TK2MSFTN GP04.phx.gbl...
"John Timney (MVP)" <x_****@timney. eclipse.co.ukwr ote in message
news:TO******** *************** *******@eclipse .net.uk...

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

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

Use this instead:

scriptString = "<script type=\"text/javascript\"fun ction 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""fun ction 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""fun ction DoClick()
{"
scriptString +=
"window.open('h ttp://www.mvps.org',' MyWindow','widt h=500,height=50 0');}<"
scriptString += "/"
scriptString += "script>"

If (Not ClientScript.Is ClientScriptBlo ckRegistered("C lientScript"))
Then
ClientScript.Re gisterClientScr iptBlock(Me.Get Type(),
"ClientScri pt", scriptString)
End If
End Sub
</script>

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

"John Timney (MVP)" <x_****@timney. eclipse.co.ukwr ote in message
news:dI******** *************** *******@eclipse .net.uk...
fair comment.....I'l l 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**@markNOSPA Mrae.comwrote in message
news:um******** ******@TK2MSFTN GP04.phx.gbl...
>"John Timney (MVP)" <x_****@timney. eclipse.co.ukwr ote in message
news:TO******* *************** ********@eclips e.net.uk...

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

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

Use this instead:

scriptString = "<script type=\"text/javascript\"fun ction 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""fun ction 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""fun ction DoClick()
{"
scriptString +=
"window.open('h ttp://www.mvps.org',' MyWindow','widt h=500,height=50 0');}<"
scriptString += "/"
scriptString += "script>"

If (Not ClientScript.Is ClientScriptBlo ckRegistered("C lientScript"))
Then
ClientScript.Re gisterClientScr iptBlock(Me.Get Type(),
"ClientScri pt", scriptString)
End If
End Sub
</script>

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

"John Timney (MVP)" <x_****@timney. eclipse.co.ukwr ote in message
news:dI******** *************** *******@eclipse .net.uk...
fair comment.....I'l l 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**@markNOSPA Mrae.comwrote in message
news:um******** ******@TK2MSFTN GP04.phx.gbl...
"John Timney (MVP)" <x_****@timney. eclipse.co.ukwr ote in message
news:TO******** *************** *******@eclipse .net.uk...

Hi John,

scriptString = "<script language=JavaSc riptfunction DoClick()
{"

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

Use this instead:

scriptString = "<script type=\"text/javascript\"fun ction 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.dt d">

<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim scriptString As String
scriptString = "<script type=""text/javascript""fun ction
DoClick() {"
scriptString +=
"window.open('p opup.aspx','MyW indow','width=5 00,height=500') ;}<"
scriptString += "/"
scriptString += "script>"
If (Not
ClientScript.Is ClientScriptBlo ckRegistered("C lientScript")) Then
ClientScript.Re gisterClientScr iptBlock(Me.Get Type(),
"ClientScri pt", scriptString)
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:HyperLin k ID="HyperLink1 " runat="server"
OnClick="DoClic k()" 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********@umb ro.co.ukwrote in message news:11******** *************@7 9g2000cws.googl egroups.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:HyperLin k ID="HyperLink1 " runat="server"
NavigateUrl="ja vascript:DoClic k()"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********@umb ro.co.ukwrote in message
news:11******** *************@4 8g2000cwx.googl egroups.com...
>
John Timney (MVP) wrote:
>Just for clarity in the thread - for VB.NET the code is
scriptString = "<script type=""text/javascript""fun ction 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""fun ction
DoClick()
{"
scriptString +=
"window.open(' http://www.mvps.org',' MyWindow','widt h=500,height=50 0');}<"
scriptString += "/"
scriptString += "script>"

If (Not
ClientScript.I sClientScriptBl ockRegistered(" ClientScript"))
Then
ClientScript.Re gisterClientScr iptBlock(Me.Get Type(),
"ClientScript" , scriptString)
End If
End Sub
</script>

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

"John Timney (MVP)" <x_****@timney. eclipse.co.ukwr ote in message
news:dI******* *************** ********@eclips e.net.uk...
fair comment.....I'l l 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**@markNOSPA Mrae.comwrote in message
news:um******** ******@TK2MSFTN GP04.phx.gbl...
"John Timney (MVP)" <x_****@timney. eclipse.co.ukwr ote in message
news:TO******* *************** ********@eclips e.net.uk...

Hi John,

scriptString = "<script language=JavaSc riptfunction
DoClick()
{"

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

Use this instead:

scriptString = "<script type=\"text/javascript\"fun ction 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.dt d">

<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim scriptString As String
scriptString = "<script type=""text/javascript""fun ction
DoClick() {"
scriptString +=
"window.open('p opup.aspx','MyW indow','width=5 00,height=500') ;}<"
scriptString += "/"
scriptString += "script>"
If (Not
ClientScript.Is ClientScriptBlo ckRegistered("C lientScript")) Then
ClientScript.Re gisterClientScr iptBlock(Me.Get Type(),
"ClientScri pt", scriptString)
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:HyperLin k ID="HyperLink1 " runat="server"
OnClick="DoClic k()" 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:HyperLin k ID="HyperLink1 " runat="server"
NavigateUrl=" javascript:DoCl ick()"HyperLink </asp:HyperLink>

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

HyperLink1.attr ibutes.add("onc lick", "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:HyperLin k 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.comwro te in message
news:11******** *************@7 9g2000cws.googl egroups.com...
John Timney (MVP) wrote:
>>>Change your hyperlink declaration to:
<asp:HyperLi nk ID="HyperLink1 " runat="server"
NavigateUrl= "javascript:DoC lick()"HyperLin k</asp:HyperLink>


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

HyperLink1.attr ibutes.add("onc lick", "DoClick()" )

Alexander Higgins
http://www.affordablewebdesignsinc.com

Dec 22 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
33571
by: Paul Eaton | last post by:
Hi I am developing my first asp appication (vbscript). I am storing cheques scans (in pdf format) in the file system along with the db on the server. The following code is working without problem except that:- I want to display the scan/pdf in a new window and keep the current window at the current position within the application.
0
4953
by: amita | last post by:
hi, 1.I want to show a image file of type '.tif' in the browser window; for that I'm writting as ASP code page. 2.This '.tif' type image can be shown better with 'Kodak Image Control'. 3.To have this 'Kodak Image Control' on my code page I just add it's ..ocx to tool box and then drag it from 'Toolbox' to the page.
1
1826
by: Krechting | last post by:
Hi All, I need a button on my form that opens a new window. I put in a submit button but it always returns to my first page. And then my first page is empty. What button do I need to go to another page (weapon_related)? This is what I use at the moment: 'NewRecord1 Operation Method @3-0C905987
6
1840
by: n2K | last post by:
Hello to all. I would like to open a new window (Function is called NewWindow and is writtent in VBscript) when a user submits a form. All the samples I found on the web indicate something like the following: <%@ Language=VBScript %> <html> <head> </head> <body>
5
8332
by: David | last post by:
Hi I don't want to use javascript to open a new window because I want to use server side code which gives me more control. I think I can not use response.redirect to open a new window and keep the current window. Is there any way to do it? Thank you! David
1
1165
by: msnews | last post by:
I have a button on an asp.net page that has the following code.. machinename = TextBox1.Text Response.Redirect("remote.asp?machinename=" & machinename) I couldn't figure out how to lauch vbscript on the client using asp.net, so I put it into so asp.
0
1515
by: thomas | last post by:
I found John Viescas's book "Access2003 Inside and Out" most helpful especially the section on Data Access Pages, and as such I have successfully launched a Intranet Web site whereby 4 remote sites can now view the information. Anyway here is my problem. I used the "Image Control" to bind 6 photos via a Parameter Query with the drive path to each photo stored in a table. So far this works great and the co-workers are impressed. However...
3
1017
by: frank | last post by:
There are some methods for redirect to another aspx page. response.redirect() server.transfer() Is it possible to open a new browser window which is not using javascript. Thanks!
6
5364
by: Jeff | last post by:
hey guys, this may not be the right place, but i wanted to give it a shot. i have an if statement, based on the data of a mssql db. if the if is .eof do nothing else
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9492
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10108
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.