Solved

JavaScript - open a new window from button click

Posted on 2010-11-30
6
339 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
key press alert 2 32
Html input text color the frame line 2 20
what is the best Integrated development environment 2 20
JS Event Does not Trigger From File 2 26
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

840 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