Solved

JavaScript - open a new window from button click

Posted on 2010-11-30
6
336 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
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now