Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a new window with set height/width

Status
Not open for further replies.

cocopud

Technical User
Jan 8, 2002
139
US
I have a webpage that I have been trying to create a link on and open that in a new window. I am finally able to get it to open in the new window, but I would like to set the height/width of the window. I have tried to add code for VBscript and javascript, but when I click on the link it says Error on Page.
I currently have this link. Is there an easy way to add something to it to open in a new window.
<a href =WhatsNew.htm target = blank><center><font size+4 color=black>What's New</font></center></href>

I was told that to do that I would need to use vb or javascript, can someone help me with the code and where it should go. I have searched this forum and tried all the example given, but the link just will not work. I'll outline the current structure of the asp page. Thanks. Any help is greatly appreciated

<%@ Language=VBScript %>
<%
if Session("user") = "" then
Response.Redirect "loginpage.asp"
end if

Session("page_id") = 0
Session("navbar_style") = "VL"

dim i
Dim pstrWrite
dim pstrWritetop

dim pobjMsgs, adoRS

Set pobjMsgs = Server.CreateObject etc. etc

%>

<!-- #Include File = "Include/Header.Asp" -->

<!-- #Include File = "Include/navbar.Asp" -->

<a href =WebFSEP_WhatsNew.htm><center><font size+4 color=black>What's New in WebFSEP</font></center></href>

<%
MORE pstrWrites here
%>
<a href = 'index.htm'><center>Web Page</center></href>

<!-- #Include File = "Include/footer.Asp" -->

<%
'pstrWrite = pstrWrite & "</body>" & vbCrLf
'pstrWrite = pstrWrite & "</html>" & vbCrLf
'Response.Write pstrWrite
%>
<SCRIPT LANGUAGE=javascript>
function fnOk(){
//Validate User Id and passowrds for Non Blanks
//
MORE CODE HERE
/SCRIPT>
 

To fix your problem, you'd need to use window.open:

Code:
<a href="javascript:void(0);" onclick="window.open('WhatsNew.htm', '', 'width=400,height=300');">What's New</a>

That aside, you don't close the HREF, you close the A. Get rid of the FONT element and replace with CSS. FONT elements are no longer part of the HTML or XHTML standards. And why centre the text inside the A when the A is only as wide as the text in it (assuming, of course, you've not made it wider using CSS)?

Hope this helps,
Dan


The answers you get are only as good as the information you give!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top