Solved

JavaScript - open a new window from button click

Posted on 2010-11-30
6
341 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
Industry Leaders: 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending ASP to server side 8 28
Can't get js code to execute 8 30
Hta File displays dynamic File names 4 44
Validating number not work with decimal 4 23
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

735 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