Solved

JavaScript - open a new window from button click

Posted on 2010-11-30
6
342 Views
Last Modified: 2012-06-27
Hi,
I can't work out how to open a new window 900px wide by 800px high when the button is clicked?


<input name="button" type="button" class="formbutton_admin" id="button" onClick="javascript:preview_template(document.getElementById('template_name').value,document.getElementById('template_style').value)" value="Preview Template">


<script type="text/javascript">

function preview_template(name,style){      
            var name = name;
             var style = style;
            self.location = "preview.php?template_name="+name+"&style="+style;
}

 function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

</script>

Your comments and feedback would be appreciated.
0
Comment
Question by:sabecs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Expert Comment

by:chrios
ID: 34238645
Have a look at this link and see if it's of help to you.

http://javascript.internet.com/generators/popup-window.html
0
 
LVL 12

Expert Comment

by:rajapandian_81
ID: 34238736
Try below code:

<input name="button" type="button" id="button" onclick="window.open('HTMLPage1.htm', 'Template', 'width=900px, height=800px');" value="Preview Template" />

Open in new window

0
 
LVL 2

Accepted Solution

by:
sajjadz earned 500 total points
ID: 34238765
try the following code:
<html>
<body >

<input type=text name=template_name id=template_name value="test" />
<input type=text name=template_style id=template_style value="test" />
<input name="button" type="button" class="formbutton_admin" id="button" value="ok " onClick="javascript:openP();" />


<script language="javascript" type="text/javascript">
	function openPopup(url){
		my_win=window.open(url,'mywindow','width=900px,height=800px,left = 100,top = 200');  
	}
	
	function openP(){
		tname = document.getElementById('template_name').value;
		tstyle = document.getElementById('template_style').value;
		
	    var url = "preview.php?template_name="+tname+"&style="+tstyle;
		
	    openPopup(url);
	}
	

</script>
</body>
</html>

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:sajjadz
ID: 34238777
sorry, use "Preview Template" instead of "Ok" in button value
0
 
LVL 6

Expert Comment

by:Codebot
ID: 34238790
0
 

Author Closing Comment

by:sabecs
ID: 34238898
Thanks  sajjadz, its perfect..
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question